Skip to content

Instantly share code, notes, and snippets.

Last active June 17, 2020 21:13
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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|
puts follow.account_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment