mirror of
https://github.com/discourse/discourse.git
synced 2024-12-25 17:23:50 +08:00
3137e60653
This PR introduces a basic AdminNotice model to store these notices. Admin notices are categorized by their source/type (currently only notices from problem check.) They also have a priority.
39 lines
715 B
Ruby
39 lines
715 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ProblemCheck::SidekiqCheck < ProblemCheck
|
|
self.priority = "low"
|
|
|
|
def call
|
|
if jobs_in_queue? && !jobs_performed_recently?
|
|
return problem(override_key: "dashboard.problem.sidekiq")
|
|
end
|
|
|
|
if massive_queue?
|
|
return(
|
|
problem(
|
|
override_key: "dashboard.problem.queue_size",
|
|
override_data: {
|
|
queue_size: Jobs.queued,
|
|
},
|
|
)
|
|
)
|
|
end
|
|
|
|
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
|