From 0491b9bf1871796155bebd2545554998c4cfed3b Mon Sep 17 00:00:00 2001 From: Gabriel Simmer Date: Sun, 26 Apr 2026 11:27:10 +0100 Subject: [PATCH] Add configurable limit to accounts prune --- lib/mastodon/cli/accounts.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/mastodon/cli/accounts.rb b/lib/mastodon/cli/accounts.rb index e4c1aac1287..13361743444 100644 --- a/lib/mastodon/cli/accounts.rb +++ b/lib/mastodon/cli/accounts.rb @@ -497,6 +497,7 @@ module Mastodon::CLI option :concurrency, type: :numeric, default: 5, aliases: [:c] option :dry_run, type: :boolean + option :limit, type: :numeric, aliases: [:l] desc 'prune', 'Prune remote accounts that never interacted with local users' long_desc <<-LONG_DESC Prune remote account that @@ -508,7 +509,7 @@ module Mastodon::CLI - not muted/blocked by us LONG_DESC def prune - _, deleted = parallelize_with_progress(prunable_accounts) do |account| + _, deleted = parallelize_with_progress(prunable_accounts(options[:limit])) do |account| next if account.bot? || account.group? next if account.suspended? next if account.silenced? @@ -573,7 +574,7 @@ module Mastodon::CLI private - def prunable_accounts + def prunable_accounts(limit = nil) Account .remote .non_automated @@ -588,6 +589,7 @@ module Mastodon::CLI .where.not(referencing_account(Report, :target_account_id)) .where.not(referencing_account(FollowRequest, :account_id)) .where.not(referencing_account(FollowRequest, :target_account_id)) + .limit(limit) end def referencing_account(model, attribute)