Skip to content

Instantly share code, notes, and snippets.

@tribela
Last active February 10, 2020 08:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tribela/09bfdcccbcbb88d538c5f01b3465c404 to your computer and use it in GitHub Desktop.
Save tribela/09bfdcccbcbb88d538c5f01b3465c404 to your computer and use it in GitHub Desktop.
Find empty account from mastodon
# frozen_string_literal: true
Account
.local.without_suspended
.where('accounts.created_at < ?', 30.days.ago)
.where(note: '')
.where(display_name: '')
.where(avatar_file_name: nil)
.where(
Account.arel_table[:fields].eq(nil).or(
Account.arel_table[:fields].eq([])
)
)
.joins(:account_stat)
.where('account_stats.statuses_count': 0)
.find_in_batches do |accs|
accs.each do |acc|
p "#{acc.id} #{acc.username}"
# SuspendAccountService.new.call(acc)
end
end
@tcitworld
Copy link

tcitworld commented Feb 10, 2020

I added this to avoid suspending my own server actor.

.where('accounts.id > ?', 0)

EDIT: Filtering on the actor_type may be useful as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment