Skip to content

Instantly share code, notes, and snippets.

@ClearlyClaire
Created April 3, 2018 16:16
Show Gist options
  • Save ClearlyClaire/ef10596c4df0e1650e49580ff146929d to your computer and use it in GitHub Desktop.
Save ClearlyClaire/ef10596c4df0e1650e49580ff146929d to your computer and use it in GitHub Desktop.
def migrated_accounts(account)
followed = Follow.where(account: account).pluck(:target_account_id)
migrated = Account.where(id: followed).where.not(moved_to_account_id: nil)
migrated = migrated.where.not(moved_to_account_id: followed)
migrated
end
def autosubscribe_migrated_accounts(account_id)
account = Account.find_by(id: account_id)
migrated = migrated_accounts(account)
Account.where(id: migrated.pluck(:moved_to_account_id)).each do |target|
FollowService.new.call(account, target)
end
end
autosubscribe_migrated_accounts(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment