report.rb 1.13 KB
Newer Older
1
# frozen_string_literal: true
yhirano's avatar
yhirano committed
2 3 4 5 6 7 8 9 10
# == Schema Information
#
# Table name: reports
#
#  status_ids                 :integer          default([]), not null, is an Array
#  comment                    :text             default(""), not null
#  action_taken               :boolean          default(FALSE), not null
#  created_at                 :datetime         not null
#  updated_at                 :datetime         not null
11 12 13 14
#  account_id                 :bigint           not null
#  action_taken_by_account_id :bigint
#  id                         :bigint           not null, primary key
#  target_account_id          :bigint           not null
yhirano's avatar
yhirano committed
15
#
16 17 18 19

class Report < ApplicationRecord
  belongs_to :account
  belongs_to :target_account, class_name: 'Account'
20
  belongs_to :action_taken_by_account, class_name: 'Account'
21 22 23

  scope :unresolved, -> { where(action_taken: false) }
  scope :resolved,   -> { where(action_taken: true) }
24

25 26
  validates :comment, length: { maximum: 1000 }

27
  def statuses
28
    Status.where(id: status_ids).includes(:account, :media_attachments, :mentions)
29
  end
30 31

  def media_attachments
32
    MediaAttachment.where(status_id: status_ids)
33
  end
34
end