Class: AbuseReportsFinder

Inherits:
Object
  • Object
show all
Defined in:
app/finders/abuse_reports_finder.rb

Constant Summary collapse

STATUS_OPEN =
'open'
DEFAULT_SORT_STATUS_CLOSED =
'created_at_desc'
ALLOWED_SORT =
DEFAULT_SORT_STATUS_CLOSED, *%w[created_at_asc updated_at_desc updated_at_asc]].freeze
DEFAULT_SORT_STATUS_OPEN =
'number_of_reports_desc'
SORT_BY_COUNT =
[DEFAULT_SORT_STATUS_OPEN].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ AbuseReportsFinder

Returns a new instance of AbuseReportsFinder.



14
15
16
17
# File 'app/finders/abuse_reports_finder.rb', line 14

def initialize(params = {})
  @params = params
  @reports = AbuseReport.all
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



4
5
6
# File 'app/finders/abuse_reports_finder.rb', line 4

def params
  @params
end

#reportsObject (readonly)

Returns the value of attribute reports.



4
5
6
# File 'app/finders/abuse_reports_finder.rb', line 4

def reports
  @reports
end

Instance Method Details

#executeObject



19
20
21
22
23
24
25
26
27
# File 'app/finders/abuse_reports_finder.rb', line 19

def execute
  @reports = reports.with_labels if Feature.enabled?(:abuse_report_labels)

  filter_reports
  aggregate_reports
  sort_reports

  reports.with_users.page(params[:page])
end