about summary refs log tree commit diff
path: root/app/controllers/admin/reports_controller.rb
diff options
context:
space:
mode:
authorMatt Jankowski <mjankowski@thoughtbot.com>2017-04-18 13:36:18 -0400
committerEugen <eugen@zeonfederated.com>2017-04-18 19:36:18 +0200
commit66d8f99a30f9e6062f1bff37d5115beddce9b55d (patch)
tree5f7c752043054bc86fb57faa89332660688044bc /app/controllers/admin/reports_controller.rb
parentf23281e31ead38a1cabbb73f0dbb8b36cb38cadb (diff)
Admin reports with accounts (#2092)
* 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
Diffstat (limited to 'app/controllers/admin/reports_controller.rb')
-rw-r--r--app/controllers/admin/reports_controller.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/app/controllers/admin/reports_controller.rb b/app/controllers/admin/reports_controller.rb
index 4a6f9ea7f..fc63ca5c0 100644
--- a/app/controllers/admin/reports_controller.rb
+++ b/app/controllers/admin/reports_controller.rb
@@ -49,14 +49,18 @@ module Admin
     end
 
     def filtered_reports
-      filtering_scope.order('id desc').includes(
+      ReportFilter.new(filter_params).results.order('id desc').includes(
         :account,
         :target_account
       )
     end
 
-    def filtering_scope
-      params[:resolved].present? ? Report.resolved : Report.unresolved
+    def filter_params
+      params.permit(
+        :account_id,
+        :resolved,
+        :target_account_id
+      )
     end
 
     def set_report