@ -89,19 +89,19 @@ class Status < ApplicationRecord
scope :without_replies , - > { where ( 'statuses.reply = FALSE OR statuses.in_reply_to_account_id = statuses.account_id' ) }
scope :without_reblogs , - > { where ( 'statuses.reblog_of_id IS NULL' ) }
scope :with_public_visibility , - > { where ( visibility : :public ) }
scope :tagged_with , - > ( tag ) { joins ( :statuses_tags ) . where ( statuses_tags : { tag_id : tag } ) }
scope :tagged_with , - > ( tag_ids ) { joins ( :statuses_tags ) . where ( statuses_tags : { tag_id : tag_ids } ) }
scope :in_chosen_languages , - > ( account ) { where ( language : nil ) . or where ( language : account . chosen_languages ) }
scope :excluding_silenced_accounts , - > { left_outer_joins ( :account ) . where ( accounts : { silenced_at : nil } ) }
scope :including_silenced_accounts , - > { left_outer_joins ( :account ) . where . not ( accounts : { silenced_at : nil } ) }
scope :not_excluded_by_account , - > ( account ) { where . not ( account_id : account . excluded_from_timeline_account_ids ) }
scope :not_domain_blocked_by_account , - > ( account ) { account . excluded_from_timeline_domains . blank? ? left_outer_joins ( :account ) : left_outer_joins ( :account ) . where ( 'accounts.domain IS NULL OR accounts.domain NOT IN (?)' , account . excluded_from_timeline_domains ) }
scope :tagged_with_all , - > ( tags ) {
Array ( tags ) . map ( & :id ) . map ( & :to_i ) . reduce ( self ) do | result , id |
scope :tagged_with_all , - > ( tag_id s ) {
Array ( tag_ids ) . reduce ( self ) do | result , id |
result . joins ( " INNER JOIN statuses_tags t #{ id } ON t #{ id } .status_id = statuses.id AND t #{ id } .tag_id = #{ id } " )
end
}
scope :tagged_with_none , - > ( tags ) {
Array ( tags ) . map ( & :id ) . map ( & :to_i ) . reduce ( self ) do | result , id |
scope :tagged_with_none , - > ( tag_id s ) {
Array ( tag_ids ) . reduce ( self ) do | result , id |
result . joins ( " LEFT OUTER JOIN statuses_tags t #{ id } ON t #{ id } .status_id = statuses.id AND t #{ id } .tag_id = #{ id } " )
. where ( " t #{ id } .tag_id IS NULL " )
end