From 66d8f99a30f9e6062f1bff37d5115beddce9b55d Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 18 Apr 2017 13:36:18 -0400 Subject: 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 --- app/models/account.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/models/account.rb') diff --git a/app/models/account.rb b/app/models/account.rb index 259a87451..2a10f8345 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -55,6 +55,10 @@ class Account < ApplicationRecord # PuSH subscriptions has_many :subscriptions, dependent: :destroy + # Report relationships + has_many :reports + has_many :targeted_reports, class_name: 'Report', foreign_key: :target_account_id + scope :remote, -> { where.not(domain: nil) } scope :local, -> { where(domain: nil) } scope :without_followers, -> { where('(select count(f.id) from follows as f where f.target_account_id = accounts.id) = 0') } -- cgit