0
0
Fork 0

Fix incorrect frequency value in FriendsOfFriendsSource data (#29550)

This commit is contained in:
Matt Jankowski 2024-03-12 04:38:32 -04:00 committed by GitHub
parent 24319836de
commit 216cea1e27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 10 deletions

View file

@ -2,15 +2,19 @@
class AccountSuggestions::FriendsOfFriendsSource < AccountSuggestions::Source
def get(account, limit: DEFAULT_LIMIT)
source_query(account, limit: limit)
.map { |id, _frequency, _followers_count| [id, key] }
end
def source_query(account, limit: DEFAULT_LIMIT)
first_degree = account.following.where.not(hide_collections: true).select(:id).reorder(nil)
base_account_scope(account)
.joins(:account_stat)
.where(id: Follow.where(account_id: first_degree).select(:target_account_id))
.joins(:passive_relationships).where(passive_relationships: { account_id: first_degree })
.group('accounts.id, account_stats.id')
.reorder('frequency DESC, followers_count DESC')
.reorder(frequency: :desc, followers_count: :desc)
.limit(limit)
.pluck(Arel.sql('accounts.id, COUNT(*) AS frequency'))
.map { |id, _frequency| [id, key] }
.pluck(Arel.sql('accounts.id, COUNT(*) AS frequency, followers_count'))
end
private