Skip to content

Instantly share code, notes, and snippets.

@ashfurrow
Last active June 17, 2020 21:13
Show Gist options
  • Save ashfurrow/3c787f6f1125158f254e26aac593b613 to your computer and use it in GitHub Desktop.
Save ashfurrow/3c787f6f1125158f254e26aac593b613 to your computer and use it in GitHub Desktop.
# 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