Created
April 3, 2018 16:16
-
-
Save ClearlyClaire/ef10596c4df0e1650e49580ff146929d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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