Fix incorrect frequency value in FriendsOfFriendsSource
data (#29550)
This commit is contained in:
parent
24319836de
commit
216cea1e27
2 changed files with 32 additions and 10 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue