0
0
Fork 0

Change auto-following admin-selected accounts, show in recommendations (#16078)

This commit is contained in:
Eugen Rochko 2021-04-24 17:01:43 +02:00 committed by GitHub
parent 863ae47b51
commit daccc07dc1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 228 additions and 128 deletions

View file

@ -0,0 +1,34 @@
# 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(&method(:to_ordered_list_key))
ordered_list.map { |ordered_list_key| map[ordered_list_key] }.compact.map do |account|
AccountSuggestions::Suggestion.new(
account: account,
source: key
)
end
end
def to_ordered_list_key(_account)
raise NotImplementedError
end
end