mirror of
https://github.com/mastodon/mastodon
synced 2025-01-10 20:03:22 +09:00
Extract constants for AnnualReport::*
minimum thresholds (#33469)
This commit is contained in:
parent
e8672e27e8
commit
1eb752fb38
@ -1,6 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class AnnualReport::CommonlyInteractedWithAccounts < AnnualReport::Source
|
class AnnualReport::CommonlyInteractedWithAccounts < AnnualReport::Source
|
||||||
|
MINIMUM_INTERACTIONS = 1
|
||||||
SET_SIZE = 40
|
SET_SIZE = 40
|
||||||
|
|
||||||
def generate
|
def generate
|
||||||
@ -17,6 +18,10 @@ class AnnualReport::CommonlyInteractedWithAccounts < AnnualReport::Source
|
|||||||
private
|
private
|
||||||
|
|
||||||
def commonly_interacted_with_accounts
|
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(count_all: :desc).limit(SET_SIZE).count
|
report_statuses.where.not(in_reply_to_account_id: @account.id).group(:in_reply_to_account_id).having(minimum_interaction_count).order(count_all: :desc).limit(SET_SIZE).count
|
||||||
|
end
|
||||||
|
|
||||||
|
def minimum_interaction_count
|
||||||
|
Arel.star.count.gt(MINIMUM_INTERACTIONS)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class AnnualReport::MostRebloggedAccounts < AnnualReport::Source
|
class AnnualReport::MostRebloggedAccounts < AnnualReport::Source
|
||||||
|
MINIMUM_REBLOGS = 1
|
||||||
SET_SIZE = 10
|
SET_SIZE = 10
|
||||||
|
|
||||||
def generate
|
def generate
|
||||||
@ -17,6 +18,10 @@ class AnnualReport::MostRebloggedAccounts < AnnualReport::Source
|
|||||||
private
|
private
|
||||||
|
|
||||||
def most_reblogged_accounts
|
def most_reblogged_accounts
|
||||||
report_statuses.where.not(reblog_of_id: nil).joins(reblog: :account).group(accounts: [:id]).having('count(*) > 1').order(count_all: :desc).limit(SET_SIZE).count
|
report_statuses.where.not(reblog_of_id: nil).joins(reblog: :account).group(accounts: [:id]).having(minimum_reblog_count).order(count_all: :desc).limit(SET_SIZE).count
|
||||||
|
end
|
||||||
|
|
||||||
|
def minimum_reblog_count
|
||||||
|
Arel.star.count.gt(MINIMUM_REBLOGS)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class AnnualReport::TopHashtags < AnnualReport::Source
|
class AnnualReport::TopHashtags < AnnualReport::Source
|
||||||
|
MINIMUM_TAGGINGS = 1
|
||||||
SET_SIZE = 40
|
SET_SIZE = 40
|
||||||
|
|
||||||
def generate
|
def generate
|
||||||
@ -17,7 +18,11 @@ class AnnualReport::TopHashtags < AnnualReport::Source
|
|||||||
private
|
private
|
||||||
|
|
||||||
def top_hashtags
|
def top_hashtags
|
||||||
Tag.joins(:statuses).where(statuses: { id: report_statuses.select(:id) }).group(coalesced_tag_names).having('count(*) > 1').order(count_all: :desc).limit(SET_SIZE).count
|
Tag.joins(:statuses).where(statuses: { id: report_statuses.select(:id) }).group(coalesced_tag_names).having(minimum_taggings_count).order(count_all: :desc).limit(SET_SIZE).count
|
||||||
|
end
|
||||||
|
|
||||||
|
def minimum_taggings_count
|
||||||
|
Arel.star.count.gt(MINIMUM_TAGGINGS)
|
||||||
end
|
end
|
||||||
|
|
||||||
def coalesced_tag_names
|
def coalesced_tag_names
|
||||||
|
Loading…
Reference in New Issue
Block a user