Class: ProblemCheck
- Inherits:
-
Object
show all
- Includes:
- ActiveSupport::Configurable
- Defined in:
- app/models/problem_check.rb
Direct Known Subclasses
EmailPollingErroredRecently, FacebookConfig, FailingEmails, ForceHttps, GithubConfig, GoogleAnalyticsVersion, GoogleOauth2Config, GroupEmailCredentials, HostNames, ImageMagick, InlineProblemCheck, MaxmindDbConfiguration, MissingMailgunApiKey, OutOfDateThemes, RailsEnv, Ram, S3BackupConfig, S3Cdn, S3UploadConfig, SidekiqCheck, SubfolderEndsInSlash, TranslationOverrides, TwitterConfig, TwitterLogin, UnreachableThemes, WatchedWords
Defined Under Namespace
Classes: BadFaviconUrl, Collection, EmailPollingErroredRecently, FacebookConfig, FailingEmails, ForceHttps, GithubConfig, GoogleAnalyticsVersion, GoogleOauth2Config, GroupEmailCredentials, HostNames, ImageMagick, InlineProblemCheck, MaxmindDbConfiguration, MissingMailgunApiKey, OutOfDateThemes, PollPop3AuthError, PollPop3Timeout, Problem, RailsEnv, Ram, S3BackupConfig, S3Cdn, S3UploadConfig, SidekiqCheck, SubfolderEndsInSlash, TranslationOverrides, TwitterConfig, TwitterLogin, UnreachableThemes, WatchedWords
Constant Summary
collapse
- CORE_PROBLEM_CHECKS =
Problem check classes need to be registered here in order to be enabled.
Note: This list must come after the ‘config_accessor` declarations.
[
ProblemCheck::BadFaviconUrl,
ProblemCheck::EmailPollingErroredRecently,
ProblemCheck::FacebookConfig,
ProblemCheck::FailingEmails,
ProblemCheck::ForceHttps,
ProblemCheck::GithubConfig,
ProblemCheck::GoogleAnalyticsVersion,
ProblemCheck::GoogleOauth2Config,
ProblemCheck::GroupEmailCredentials,
ProblemCheck::HostNames,
ProblemCheck::ImageMagick,
ProblemCheck::MissingMailgunApiKey,
ProblemCheck::OutOfDateThemes,
ProblemCheck::PollPop3Timeout,
ProblemCheck::PollPop3AuthError,
ProblemCheck::RailsEnv,
ProblemCheck::Ram,
ProblemCheck::S3BackupConfig,
ProblemCheck::S3Cdn,
ProblemCheck::S3UploadConfig,
ProblemCheck::SidekiqCheck,
ProblemCheck::SubfolderEndsInSlash,
ProblemCheck::TranslationOverrides,
ProblemCheck::TwitterConfig,
ProblemCheck::TwitterLogin,
ProblemCheck::UnreachableThemes,
ProblemCheck::WatchedWords,
].freeze
- NO_TARGET =
To enforce the unique constraint in Postgres <15 we need a dummy value, since the index considers NULLs to be distinct.
"__NULL__"
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data = {}) ⇒ ProblemCheck
Returns a new instance of ProblemCheck.
148
149
150
|
# File 'app/models/problem_check.rb', line 148
def initialize(data = {})
@data = OpenStruct.new(data)
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
152
153
154
|
# File 'app/models/problem_check.rb', line 152
def data
@data
end
|
Class Method Details
.[](key) ⇒ Object
97
98
99
100
101
|
# File 'app/models/problem_check.rb', line 97
def self.[](key)
key = key.to_sym
checks.find { |c| c.identifier == key }
end
|
.call(data = {}) ⇒ Object
140
141
142
|
# File 'app/models/problem_check.rb', line 140
def self.call(data = {})
new(data).call
end
|
.enabled? ⇒ Boolean
120
121
122
|
# File 'app/models/problem_check.rb', line 120
def self.enabled?
enabled
end
|
.identifier ⇒ Object
115
116
117
|
# File 'app/models/problem_check.rb', line 115
def self.identifier
name.demodulize.underscore.to_sym
end
|
.inline? ⇒ Boolean
135
136
137
|
# File 'app/models/problem_check.rb', line 135
def self.inline?
inline
end
|
.realtime ⇒ Object
111
112
113
|
# File 'app/models/problem_check.rb', line 111
def self.realtime
Collection.new(checks.select(&:realtime?))
end
|
.realtime? ⇒ Boolean
130
131
132
|
# File 'app/models/problem_check.rb', line 130
def self.realtime?
!scheduled? && !inline?
end
|
.run(data = {}) ⇒ Object
144
145
146
|
# File 'app/models/problem_check.rb', line 144
def self.run(data = {}, &)
new(data).run(&)
end
|
.scheduled ⇒ Object
107
108
109
|
# File 'app/models/problem_check.rb', line 107
def self.scheduled
Collection.new(checks.select(&:scheduled?))
end
|
.scheduled? ⇒ Boolean
125
126
127
|
# File 'app/models/problem_check.rb', line 125
def self.scheduled?
perform_every.present?
end
|
Instance Method Details
#call ⇒ Object
154
155
156
|
# File 'app/models/problem_check.rb', line 154
def call
raise NotImplementedError
end
|
#run {|problems| ... } ⇒ Object
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
# File 'app/models/problem_check.rb', line 158
def run
problems = call
yield(problems) if block_given?
next_run_at = perform_every&.from_now
if problems.empty?
targets.each { |t| tracker(t).no_problem!(next_run_at:) }
else
problems
.uniq(&:target)
.each do |problem|
tracker(problem.target).problem!(
next_run_at:,
details: translation_data.merge(problem.details).merge(base_path: Discourse.base_path),
)
end
end
problems
end
|