Last active
January 3, 2023 21:46
-
-
Save Aeramor/ace93395f2def4a78d74 to your computer and use it in GitHub Desktop.
Remove Duplicate resque jobs - ActiveJob
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
key = 'queue:default' | |
if Resque.redis.exists(key) | |
members = Resque.redis.lrange(key, 0, -1) | |
duplicate_members = members.group_by { |e| JSON.parse(e)["args"][0].except("job_id").to_s }.select { |k, v| v.size > 1 }.map{ |a| a[1].drop(1) }.flatten | |
duplicate_members.each do |duplicate_member| | |
Resque.redis.lrem(key, -1, duplicate_member) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment