mirror of
https://framagit.org/tykayn/mastodon.git
synced 2023-08-25 08:33:12 +02:00
66d8f99a30
* Add a ReportFilter class * Add reports and targeted_reports relationships to Account * Use ReportFilter from admin/reports controller * Link to admin/reports filtered views from admin account show view * Add indexes to reports.account_id and reports.target_account_id
31 lines
560 B
Ruby
31 lines
560 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ReportFilter
|
|
attr_reader :params
|
|
|
|
def initialize(params)
|
|
@params = params
|
|
end
|
|
|
|
def results
|
|
scope = Report.unresolved
|
|
params.each do |key, value|
|
|
scope = scope.merge scope_for(key, value)
|
|
end
|
|
scope
|
|
end
|
|
|
|
def scope_for(key, value)
|
|
case key.to_sym
|
|
when :resolved
|
|
Report.resolved
|
|
when :account_id
|
|
Report.where(account_id: value)
|
|
when :target_account_id
|
|
Report.where(target_account_id: value)
|
|
else
|
|
raise "Unknown filter: #{key}"
|
|
end
|
|
end
|
|
end
|