suggestion_serializer.rb 564 B

1234567891011121314151617181920
  1. # frozen_string_literal: true
  2. class REST::SuggestionSerializer < ActiveModel::Serializer
  3. attributes :source, :sources
  4. has_one :account, serializer: REST::AccountSerializer
  5. LEGACY_SOURCE_TYPE_MAP = {
  6. featured: 'staff',
  7. most_followed: 'global',
  8. most_interactions: 'global',
  9. # NOTE: Those are not completely accurate, but those are personalized interactions
  10. similar_to_recently_followed: 'past_interactions',
  11. friends_of_friends: 'past_interactions',
  12. }.freeze
  13. def source
  14. LEGACY_SOURCE_TYPE_MAP[object.sources.first]
  15. end
  16. end