You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
713 B

  1. # frozen_string_literal: true
  2. class AccountSuggestions
  3. SOURCES = [
  4. AccountSuggestions::SettingSource,
  5. AccountSuggestions::PastInteractionsSource,
  6. AccountSuggestions::GlobalSource,
  7. ].freeze
  8. def self.get(account, limit)
  9. SOURCES.each_with_object([]) do |source_class, suggestions|
  10. source_suggestions = source_class.new.get(
  11. account,
  12. skip_account_ids: suggestions.map(&:account_id),
  13. limit: limit - suggestions.size
  14. )
  15. suggestions.concat(source_suggestions)
  16. end
  17. end
  18. def self.remove(account, target_account_id)
  19. SOURCES.each do |source_class|
  20. source = source_class.new
  21. source.remove(account, target_account_id)
  22. end
  23. end
  24. end