discourse/app/services/problem_check/sidekiq_check.rb
Ted Johansson 4ca41e0af2
DEV: Promote block problem checks to ProblemCheck (#26193)
In #26122 we promoted all problem checks defined as class methods on AdminDashboardData to their own first-class ProblemCheck instances.

This PR continues that by promoting problem checks that are implemented as blocks as well. This includes updating a couple plugins that have problem checks.
2024-03-20 08:52:25 +08:00

27 lines
568 B
Ruby

# frozen_string_literal: true
class ProblemCheck::SidekiqCheck < ProblemCheck
self.priority = "low"
def call
return problem("dashboard.sidekiq_warning") if jobs_in_queue? && !jobs_performed_recently?
return problem("dashboard.queue_size_warning", queue_size: Jobs.queued) if massive_queue?
no_problem
end
private
def massive_queue?
Jobs.queued >= 100_000
end
def jobs_in_queue?
Jobs.queued > 0
end
def jobs_performed_recently?
Jobs.last_job_performed_at.present? && Jobs.last_job_performed_at > 2.minutes.ago
end
end