Skip to content

Commit

Permalink
Ignore future jobs in jobs:check.
Browse files Browse the repository at this point in the history
If there are scheduled jobs in the future, they should not be included in the jobs:check, which is intended to look for jobs that should be processed but have not yet been processed.
  • Loading branch information
joshuapinter committed Aug 24, 2022
1 parent 40f8384 commit 4cbb738
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/delayed/tasks.rb
Expand Up @@ -30,7 +30,7 @@
task :check, [:max_age, :not_locked] => :environment do |_, args|
args.with_defaults(:max_age => 300, :not_locked => false)

unprocessed_jobs = Delayed::Job.where('attempts = 0 AND created_at < ?', Time.now - args[:max_age].to_i)
unprocessed_jobs = Delayed::Job.where('attempts = 0 AND created_at < ? AND run_at <= ?', Time.now - args[:max_age].to_i, Time.now)
unprocessed_jobs = unprocessed_jobs.where('locked_at IS NULL') if args[:not_locked]
unprocessed_jobs = unprocessed_jobs.count

Expand Down

0 comments on commit 4cbb738

Please sign in to comment.