Skip to content

Instantly share code, notes, and snippets.

@aschmitz
Created October 12, 2017 14:23
Show Gist options
  • Save aschmitz/4a85c58b3e35a364af26530ff79dbcf8 to your computer and use it in GitHub Desktop.
Save aschmitz/4a85c58b3e35a364af26530ff79dbcf8 to your computer and use it in GitHub Desktop.
# To get a list of affected accounts
affected = []
bad_entry_count = 0
redis = Redis.current
Account.find_each do |account|
key = FeedManager.instance.key(:home, account)
values = redis.zrange(key, 0, -1)
bad = values.select { |val| val.include?('e') }
unless bad.empty?
affected << account.id
bad_entry_count += bad.count
bad.each { |val| redis.zrem(key, val) }
end
end
puts "#{bad_entry_count} entries in #{affected.count} feeds were affected"
# Run this if you want. It will restore the affected statuses if they're in the
# first MAX_ITEM/4 statuses, but at the cost of somewhat significant database
# load.
affected.each do |account_id|
FeedManager.instance.populate_feed(Account.find(account_id))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment