From 90eb9f6f4c18eb43922efbeffa2ba7d277d8074e Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Mon, 29 Apr 2024 08:27:17 -0400 Subject: [PATCH] Add `Account.without_migrated` scope --- app/models/account.rb | 3 ++- app/models/relationship_filter.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/account.rb b/app/models/account.rb index 8a990bb831d..97ae9e7bb9a 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -125,6 +125,7 @@ class Account < ApplicationRecord scope :without_suspended, -> { where(suspended_at: nil) } scope :without_silenced, -> { where(silenced_at: nil) } scope :without_instance_actor, -> { where.not(id: INSTANCE_ACTOR_ID) } + scope :without_migrated, -> { where(moved_to_account_id: nil) } scope :recent, -> { reorder(id: :desc) } scope :bots, -> { where(actor_type: %w(Application Service)) } scope :groups, -> { where(actor_type: 'Group') } @@ -134,7 +135,7 @@ class Account < ApplicationRecord scope :matches_display_name, ->(value) { where(arel_table[:display_name].matches("#{value}%")) } scope :without_unapproved, -> { left_outer_joins(:user).merge(User.approved.confirmed).or(remote) } scope :auditable, -> { where(id: Admin::ActionLog.select(:account_id).distinct) } - scope :searchable, -> { without_unapproved.without_suspended.where(moved_to_account_id: nil) } + scope :searchable, -> { without_unapproved.without_suspended.without_migrated } scope :discoverable, -> { searchable.without_silenced.where(discoverable: true).joins(:account_stat) } scope :by_recent_status, -> { includes(:account_stat).merge(AccountStat.by_recent_status).references(:account_stat) } scope :by_recent_activity, -> { left_joins(:user, :account_stat).order(coalesced_activity_timestamps.desc).order(id: :desc) } diff --git a/app/models/relationship_filter.rb b/app/models/relationship_filter.rb index 828610e46a4..d597c2068ef 100644 --- a/app/models/relationship_filter.rb +++ b/app/models/relationship_filter.rb @@ -94,7 +94,7 @@ class RelationshipFilter when 'moved' Account.where.not(moved_to_account_id: nil) when 'primary' - Account.where(moved_to_account_id: nil) + Account.without_migrated else raise Mastodon::InvalidParameterError, "Unknown status: #{value}" end