Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Remove old followers
account = Account.find(1) # that's me babey
scope = account.followers.eager_load(:account_stat).reorder(nil)
scope.merge! Account.by_recent_status
scope.merge! Account.local
scope.merge! AccountStat.where(last_status_at: nil).or(AccountStat.where(AccountStat.arel_table[:last_status_at].lt(6.months.ago)))
scope.count # 13146
account.passive_relationships.where(account_id: scope.pluck(:id)).find_each do |follow|
follow.destroy
puts follow.account_id
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment