Created
August 9, 2014 07:32
-
-
Save sanemat/ca0d647ea3b0798dc9e3 to your computer and use it in GitHub Desktop.
Clear job with que
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
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