Skip to content

Instantly share code, notes, and snippets.

@sanemat
Created August 9, 2014 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanemat/ca0d647ea3b0798dc9e3 to your computer and use it in GitHub Desktop.
Save sanemat/ca0d647ea3b0798dc9e3 to your computer and use it in GitHub Desktop.
Clear job with que
class JobQueue
def self.clear(job_class, *args)
case
when job_class == RepoSynchronizationJob
user_id = args.first[:user_id]
sql = <<-"EOQ".strip_heredoc
DELETE FROM que_jobs
WHERE
job_class = #{ActiveRecord::Base.connection.quote(job_class)}
AND
(args->0->>'user_id')::INT = #{ActiveRecord::Base.connection.quote(user_id)}
EOQ
ActiveRecord::Base.connection.execute(sql)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment