This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2021-04-12 03:37:14 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class AccountSuggestions
|
2021-04-24 08:01:43 -07:00
|
|
|
SOURCES = [
|
|
|
|
AccountSuggestions::SettingSource,
|
|
|
|
AccountSuggestions::PastInteractionsSource,
|
|
|
|
AccountSuggestions::GlobalSource,
|
|
|
|
].freeze
|
2021-04-12 03:37:14 -07:00
|
|
|
|
|
|
|
def self.get(account, limit)
|
2021-04-24 08:01:43 -07:00
|
|
|
SOURCES.each_with_object([]) do |source_class, suggestions|
|
|
|
|
source_suggestions = source_class.new.get(
|
|
|
|
account,
|
|
|
|
skip_account_ids: suggestions.map(&:account_id),
|
|
|
|
limit: limit - suggestions.size
|
|
|
|
)
|
|
|
|
|
|
|
|
suggestions.concat(source_suggestions)
|
|
|
|
end
|
2021-04-12 03:37:14 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.remove(account, target_account_id)
|
2021-04-24 08:01:43 -07:00
|
|
|
SOURCES.each do |source_class|
|
|
|
|
source = source_class.new
|
|
|
|
source.remove(account, target_account_id)
|
|
|
|
end
|
2021-04-12 03:37:14 -07:00
|
|
|
end
|
|
|
|
end
|