account_summary.rb 674 B

12345678910111213141516171819202122
  1. # frozen_string_literal: true
  2. # == Schema Information
  3. #
  4. # Table name: account_summaries
  5. #
  6. # account_id :bigint(8) primary key
  7. # language :string
  8. # sensitive :boolean
  9. #
  10. class AccountSummary < ApplicationRecord
  11. include DatabaseViewRecord
  12. self.primary_key = :account_id
  13. has_many :follow_recommendation_suppressions, primary_key: :account_id, foreign_key: :account_id, inverse_of: false, dependent: nil
  14. scope :safe, -> { where(sensitive: false) }
  15. scope :localized, ->(locale) { order(Arel::Nodes::Case.new.when(arel_table[:language].eq(locale)).then(1).else(0).desc) }
  16. scope :filtered, -> { where.missing(:follow_recommendation_suppressions) }
  17. end