|
@@ -85,6 +85,7 @@ class Account < ApplicationRecord
|
|
|
scope :silenced, -> { where(silenced: true) }
|
|
|
scope :suspended, -> { where(suspended: true) }
|
|
|
scope :without_suspended, -> { where(suspended: false) }
|
|
|
+ scope :without_silenced, -> { where(silenced: false) }
|
|
|
scope :recent, -> { reorder(id: :desc) }
|
|
|
scope :bots, -> { where(actor_type: %w(Application Service)) }
|
|
|
scope :alphabetic, -> { order(domain: :asc, username: :asc) }
|
|
@@ -92,8 +93,8 @@ class Account < ApplicationRecord
|
|
|
scope :matches_username, ->(value) { where(arel_table[:username].matches("#{value}%")) }
|
|
|
scope :matches_display_name, ->(value) { where(arel_table[:display_name].matches("#{value}%")) }
|
|
|
scope :matches_domain, ->(value) { where(arel_table[:domain].matches("%#{value}%")) }
|
|
|
- scope :searchable, -> { where(suspended: false).where(moved_to_account_id: nil) }
|
|
|
- scope :discoverable, -> { searchable.where(silenced: false).where(discoverable: true).joins(:account_stat).where(AccountStat.arel_table[:followers_count].gteq(MIN_FOLLOWERS_DISCOVERY)).by_recent_status }
|
|
|
+ scope :searchable, -> { without_suspended.where(moved_to_account_id: nil) }
|
|
|
+ scope :discoverable, -> { searchable.without_silenced.where(discoverable: true).joins(:account_stat).where(AccountStat.arel_table[:followers_count].gteq(MIN_FOLLOWERS_DISCOVERY)).by_recent_status }
|
|
|
scope :tagged_with, ->(tag) { joins(:accounts_tags).where(accounts_tags: { tag_id: tag }) }
|
|
|
scope :by_recent_status, -> { order(Arel.sql('(case when account_stats.last_status_at is null then 1 else 0 end) asc, account_stats.last_status_at desc')) }
|
|
|
scope :popular, -> { order('account_stats.followers_count desc') }
|