mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-14 00:08:46 +00:00
Change algorithm of follow recommendations (#28314)
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -1,34 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AccountSuggestions::Source
|
||||
def key
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def get(_account, **kwargs)
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def remove(_account, target_account_id)
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def as_ordered_suggestions(scope, ordered_list)
|
||||
return [] if ordered_list.empty?
|
||||
|
||||
map = scope.index_by { |account| to_ordered_list_key(account) }
|
||||
|
||||
ordered_list.filter_map { |ordered_list_key| map[ordered_list_key] }.map do |account|
|
||||
AccountSuggestions::Suggestion.new(
|
||||
account: account,
|
||||
source: key
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def to_ordered_list_key(_account)
|
||||
raise NotImplementedError
|
||||
def base_account_scope(account)
|
||||
Account.searchable
|
||||
.followable_by(account)
|
||||
.not_excluded_by_account(account)
|
||||
.not_domain_blocked_by_account(account)
|
||||
.where.not(id: account.id)
|
||||
.joins("LEFT OUTER JOIN follow_recommendation_mutes ON follow_recommendation_mutes.target_account_id = accounts.id AND follow_recommendation_mutes.account_id = #{account.id}").where(follow_recommendation_mutes: { target_account_id: nil })
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user