mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 03:43:39 +08:00
4ca41e0af2
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.
27 lines
568 B
Ruby
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
|