diff --git a/app/models/account_suggestions/friends_of_friends_source.rb b/app/models/account_suggestions/friends_of_friends_source.rb index 28d0ab99b3..93fb10f3b0 100644 --- a/app/models/account_suggestions/friends_of_friends_source.rb +++ b/app/models/account_suggestions/friends_of_friends_source.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class AccountSuggestions::FriendsOfFriendsSource < AccountSuggestions::Source - def get(account, limit: 10) + def get(account, limit: DEFAULT_LIMIT) Account.find_by_sql([<<~SQL.squish, { id: account.id, limit: limit }]).map { |row| [row.id, key] } WITH first_degree AS ( SELECT target_account_id diff --git a/app/models/account_suggestions/global_source.rb b/app/models/account_suggestions/global_source.rb index d68f285e4f..c05bcf2ce8 100644 --- a/app/models/account_suggestions/global_source.rb +++ b/app/models/account_suggestions/global_source.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class AccountSuggestions::GlobalSource < AccountSuggestions::Source - def get(account, limit: 10) + def get(account, limit: DEFAULT_LIMIT) FollowRecommendation.localized(content_locale).joins(:account).merge(base_account_scope(account)).order(rank: :desc).limit(limit).pluck(:account_id, :reason) end diff --git a/app/models/account_suggestions/setting_source.rb b/app/models/account_suggestions/setting_source.rb index 4b7275bf7a..9f3cd7bd3d 100644 --- a/app/models/account_suggestions/setting_source.rb +++ b/app/models/account_suggestions/setting_source.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class AccountSuggestions::SettingSource < AccountSuggestions::Source - def get(account, limit: 10) + def get(account, limit: DEFAULT_LIMIT) if setting_enabled? base_account_scope(account).where(setting_to_where_condition).limit(limit).pluck(:id).zip([key].cycle) else diff --git a/app/models/account_suggestions/similar_profiles_source.rb b/app/models/account_suggestions/similar_profiles_source.rb index 733c5f0bbc..3ece20aa51 100644 --- a/app/models/account_suggestions/similar_profiles_source.rb +++ b/app/models/account_suggestions/similar_profiles_source.rb @@ -47,7 +47,7 @@ class AccountSuggestions::SimilarProfilesSource < AccountSuggestions::Source end end - def get(account, limit: 10) + def get(account, limit: DEFAULT_LIMIT) recently_followed_account_ids = account.active_relationships.recent.limit(5).pluck(:target_account_id) if Chewy.enabled? && !recently_followed_account_ids.empty? diff --git a/app/models/account_suggestions/source.rb b/app/models/account_suggestions/source.rb index d83f5e3773..b2c3c7a3a2 100644 --- a/app/models/account_suggestions/source.rb +++ b/app/models/account_suggestions/source.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class AccountSuggestions::Source + DEFAULT_LIMIT = 10 + def get(_account, **kwargs) raise NotImplementedError end