Use group/count approach in annual report classes (#32914)

This commit is contained in:
Matt Jankowski 2024-11-19 03:51:34 -05:00 committed by GitHub
parent 295ad6f19a
commit 425982841d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 52 additions and 13 deletions

View file

@ -17,6 +17,6 @@ class AnnualReport::CommonlyInteractedWithAccounts < AnnualReport::Source
private
def commonly_interacted_with_accounts
report_statuses.where.not(in_reply_to_account_id: @account.id).group(:in_reply_to_account_id).having('count(*) > 1').order(total: :desc).limit(SET_SIZE).pluck(Arel.sql('in_reply_to_account_id, count(*) AS total'))
report_statuses.where.not(in_reply_to_account_id: @account.id).group(:in_reply_to_account_id).having('count(*) > 1').order(count_all: :desc).limit(SET_SIZE).count
end
end