You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.1 KiB

  1. # frozen_string_literal: true
  2. # == Schema Information
  3. #
  4. # Table name: reports
  5. #
  6. # status_ids :integer default([]), not null, is an Array
  7. # comment :text default(""), not null
  8. # action_taken :boolean default(FALSE), not null
  9. # created_at :datetime not null
  10. # updated_at :datetime not null
  11. # account_id :bigint not null
  12. # action_taken_by_account_id :bigint
  13. # id :bigint not null, primary key
  14. # target_account_id :bigint not null
  15. #
  16. class Report < ApplicationRecord
  17. belongs_to :account
  18. belongs_to :target_account, class_name: 'Account'
  19. belongs_to :action_taken_by_account, class_name: 'Account'
  20. scope :unresolved, -> { where(action_taken: false) }
  21. scope :resolved, -> { where(action_taken: true) }
  22. validates :comment, length: { maximum: 1000 }
  23. def statuses
  24. Status.where(id: status_ids).includes(:account, :media_attachments, :mentions)
  25. end
  26. def media_attachments
  27. MediaAttachment.where(status_id: status_ids)
  28. end
  29. end