0
0
Fork 0

Change algorithm of follow recommendations (#28314)

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Eugen Rochko 2023-12-19 11:59:43 +01:00 committed by GitHub
parent b7bdcd4f39
commit b5ac61b2c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 297 additions and 292 deletions

View file

@ -1,32 +1,18 @@
# frozen_string_literal: true
class AccountSuggestions::SettingSource < AccountSuggestions::Source
def key
:staff
end
def get(account, skip_account_ids: [], limit: 40)
return [] unless setting_enabled?
as_ordered_suggestions(
scope(account).where(setting_to_where_condition).where.not(id: skip_account_ids),
usernames_and_domains
).take(limit)
end
def remove(_account, _target_account_id)
nil
def get(account, limit: 10)
if setting_enabled?
base_account_scope(account).where(setting_to_where_condition).limit(limit).pluck(:id).zip([key].cycle)
else
[]
end
end
private
def scope(account)
Account.searchable
.followable_by(account)
.not_excluded_by_account(account)
.not_domain_blocked_by_account(account)
.where(locked: false)
.where.not(id: account.id)
def key
:featured
end
def usernames_and_domains
@ -61,8 +47,4 @@ class AccountSuggestions::SettingSource < AccountSuggestions::Source
def setting
Setting.bootstrap_timeline_accounts
end
def to_ordered_list_key(account)
[account.username.downcase, account.domain&.downcase]
end
end