account_suggestions.rb 713 B

12345678910111213141516171819202122232425262728
  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