Skip to content

Instantly share code, notes, and snippets.

@christopher-b
Last active December 20, 2015 00:08
Show Gist options
  • Save christopher-b/6038992 to your computer and use it in GitHub Desktop.
Save christopher-b/6038992 to your computer and use it in GitHub Desktop.
Canvas LMS rake task to return the number of queued delayed jobs
namespace :ocadu do
"Returns the number of delayed jobs in the queue"
task :job_count => :environment do
puts Delayed::Job.where("run_at < UTC_TIMESTAMP() AND locked_at is null").count
end
end
@christopher-b
Copy link
Author

Thanks Brian!

@christopher-b
Copy link
Author

BTW, I think for MySQL the query should be:

select count(1) from delayed_jobs where run_at < UTC_TIMESTAMP() and locked_at is null;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment