From 32a3ac18b55c0852a90c06ec7122b4c754d97caa Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 2 Jul 2025 18:45:35 -0400 Subject: [PATCH] Use `excluding` in simple applications --- app/models/account_suggestions/source.rb | 2 +- app/services/activitypub/process_account_service.rb | 2 +- app/validators/unique_username_validator.rb | 2 +- app/workers/account_merging_worker.rb | 2 +- app/workers/backup_worker.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/account_suggestions/source.rb b/app/models/account_suggestions/source.rb index 9ae6bbbcc95..4aa5c3c6541 100644 --- a/app/models/account_suggestions/source.rb +++ b/app/models/account_suggestions/source.rb @@ -19,7 +19,7 @@ class AccountSuggestions::Source .where.not(follow_requests_sql, id: account.id) .not_excluded_by_account(account) .not_domain_blocked_by_account(account) - .where.not(id: account.id) + .excluding(account) .where.not(follow_recommendation_mutes_sql, id: account.id) end diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb index 201f7513b9b..f7316a67bc7 100644 --- a/app/services/activitypub/process_account_service.rb +++ b/app/services/activitypub/process_account_service.rb @@ -198,7 +198,7 @@ class ActivityPub::ProcessAccountService < BaseService end def process_duplicate_accounts! - return unless Account.where(uri: @account.uri).where.not(id: @account.id).exists? + return unless Account.where(uri: @account.uri).excluding(@account).exists? AccountMergingWorker.perform_async(@account.id) end diff --git a/app/validators/unique_username_validator.rb b/app/validators/unique_username_validator.rb index c417e2f6962..91b22fa8c41 100644 --- a/app/validators/unique_username_validator.rb +++ b/app/validators/unique_username_validator.rb @@ -7,7 +7,7 @@ class UniqueUsernameValidator < ActiveModel::Validator return if account.username.blank? scope = Account.with_username(account.username).with_domain(account.domain) - scope = scope.where.not(id: account.id) if account.persisted? + scope = scope.excluding(account) if account.persisted? account.errors.add(:username, :taken) if scope.exists? end diff --git a/app/workers/account_merging_worker.rb b/app/workers/account_merging_worker.rb index 8c234e7acf1..a557273580f 100644 --- a/app/workers/account_merging_worker.rb +++ b/app/workers/account_merging_worker.rb @@ -10,7 +10,7 @@ class AccountMergingWorker return true if account.nil? || account.local? - Account.where(uri: account.uri).where.not(id: account.id).find_each do |duplicate| + Account.where(uri: account.uri).excluding(account).find_each do |duplicate| account.merge_with!(duplicate) duplicate.destroy end diff --git a/app/workers/backup_worker.rb b/app/workers/backup_worker.rb index df933142ae4..c9201be1935 100644 --- a/app/workers/backup_worker.rb +++ b/app/workers/backup_worker.rb @@ -22,7 +22,7 @@ class BackupWorker BackupService.new.call(backup) - user.backups.where.not(id: backup.id).destroy_all + user.backups.excluding(backup).destroy_all UserMailer.backup_ready(user, backup).deliver_later end end