about summary refs log tree commit diff
path: root/app/models/account_suggestions.rb
blob: d1774e62fae3bd5d25f243e4f2187f2ab253010f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

class AccountSuggestions
  SOURCES = [
    AccountSuggestions::SettingSource,
    AccountSuggestions::PastInteractionsSource,
    AccountSuggestions::GlobalSource,
  ].freeze

  def self.get(account, limit)
    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
  end

  def self.remove(account, target_account_id)
    SOURCES.each do |source_class|
      source = source_class.new
      source.remove(account, target_account_id)
    end
  end
end