DEV: Allow disabling problem checks programatically (#28440)

We need a way to disable certain checks programatically, e.g. on Discourse hosting. This PR adds a configuration option for this, and makes it so that disabled checks aren't run as part of #run_all.
This commit is contained in:
Ted Johansson
2024-08-20 16:42:06 +02:00
committed by GitHub
parent 0636855706
commit 948e7bd55e
2 changed files with 17 additions and 2 deletions

View File

@ -13,7 +13,7 @@ class ProblemCheck
end
def run_all
each(&:run)
select(&:enabled?).each(&:run)
end
private
@ -23,6 +23,7 @@ class ProblemCheck
include ActiveSupport::Configurable
config_accessor :enabled, default: true, instance_writer: false
config_accessor :priority, default: "low", instance_writer: false
# Determines if the check should be performed at a regular interval, and if
@ -112,6 +113,11 @@ class ProblemCheck
end
delegate :identifier, to: :class
def self.enabled?
enabled
end
delegate :enabled?, to: :class
def self.scheduled?
perform_every.present?
end