Skip to content

Instantly share code, notes, and snippets.

@Aeramor
Last active January 3, 2023 21:46
Show Gist options
  • Save Aeramor/ace93395f2def4a78d74 to your computer and use it in GitHub Desktop.
Save Aeramor/ace93395f2def4a78d74 to your computer and use it in GitHub Desktop.
Remove Duplicate resque jobs - ActiveJob
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