follow_recommendation.rb 781 B

1234567891011121314151617181920212223
  1. # frozen_string_literal: true
  2. # == Schema Information
  3. #
  4. # Table name: global_follow_recommendations
  5. #
  6. # account_id :bigint(8) primary key
  7. # rank :decimal(, )
  8. # reason :text is an Array
  9. #
  10. class FollowRecommendation < ApplicationRecord
  11. include DatabaseViewRecord
  12. self.primary_key = :account_id
  13. self.table_name = :global_follow_recommendations
  14. belongs_to :account_summary, foreign_key: :account_id, inverse_of: false
  15. belongs_to :account
  16. scope :unsupressed, -> { where.not(FollowRecommendationSuppression.where(FollowRecommendationSuppression.arel_table[:account_id].eq(arel_table[:account_id])).select(1).arel.exists) }
  17. scope :localized, ->(locale) { unsupressed.joins(:account_summary).merge(AccountSummary.localized(locale)) }
  18. end