mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-16 03:41:41 +00:00
Define some helper scopes in Delayed::Job for worker status API.
This commit is contained in:
parent
63f64f1597
commit
89cc666212
2 changed files with 9 additions and 3 deletions
|
@ -20,9 +20,9 @@ class WorkerStatusController < ApplicationController
|
|||
end
|
||||
|
||||
render json: {
|
||||
pending: Delayed::Job.where("run_at <= ? AND locked_at IS NULL AND attempts = 0", start).count,
|
||||
awaiting_retry: Delayed::Job.where("failed_at IS NULL AND attempts > 0").count,
|
||||
recent_failures: Delayed::Job.where("failed_at IS NOT NULL AND failed_at > ?", 5.days.ago).count,
|
||||
pending: Delayed::Job.pending.where("run_at <= ?", start).count,
|
||||
awaiting_retry: Delayed::Job.awaiting_retry.count,
|
||||
recent_failures: Delayed::Job.failed.where('failed_at > ?', 5.days.ago).count,
|
||||
event_count: count,
|
||||
max_id: max_id || 0,
|
||||
events_url: events_url,
|
||||
|
|
|
@ -7,3 +7,9 @@ Delayed::Worker.delay_jobs = !Rails.env.test?
|
|||
|
||||
# Delayed::Worker.logger = Logger.new(Rails.root.join('log', 'delayed_job.log'))
|
||||
# Delayed::Worker.logger.level = Logger::DEBUG
|
||||
|
||||
class Delayed::Job
|
||||
scope :pending, ->{ where("locked_at IS NULL AND attempts = 0") }
|
||||
scope :awaiting_retry, ->{ where("failed_at IS NULL AND attempts > 0") }
|
||||
scope :failed, -> { where("failed_at IS NOT NULL") }
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue