DEV: Require scheduled job in development to avoid loading file twice.

This removes the need to memoize constant in order to avoid the "warning: already initialized constant".
This commit is contained in:
Guo Xiang Tan 2020-09-01 10:12:26 +08:00
parent 09a89cff1a
commit 069a109cbb
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
5 changed files with 7 additions and 6 deletions

View File

@ -4,7 +4,7 @@ module Jobs
class GrantNewUserOfTheMonthBadges < ::Jobs::Scheduled
every 1.day
MAX_AWARDED ||= 2
MAX_AWARDED = 2
def execute(args)
badge = Badge.find(Badge::NewUserOfTheMonth)

View File

@ -4,7 +4,7 @@ module Jobs
class OldKeysReminder < ::Jobs::Scheduled
every 1.month
OLD_CREDENTIALS_PERIOD ||= 2.years
OLD_CREDENTIALS_PERIOD = 2.years
def execute(_args)
return if SiteSetting.send_old_credential_reminder_days.to_i == 0

View File

@ -23,7 +23,7 @@ module Jobs
Email::Processor.process!(popmail.pop)
end
POLL_MAILBOX_TIMEOUT_ERROR_KEY ||= "poll_mailbox_timeout_error_key"
POLL_MAILBOX_TIMEOUT_ERROR_KEY = "poll_mailbox_timeout_error_key"
def poll_pop3
pop3 = Net::POP3.new(SiteSetting.pop3_polling_host, SiteSetting.pop3_polling_port)
@ -62,7 +62,7 @@ module Jobs
Discourse.handle_job_exception(e, error_context(@args, "Signing in to poll incoming emails."))
end
POLL_MAILBOX_ERRORS_KEY ||= "poll_mailbox_errors"
POLL_MAILBOX_ERRORS_KEY = "poll_mailbox_errors"
def self.errors_in_past_24_hours
Discourse.redis.zremrangebyscore(POLL_MAILBOX_ERRORS_KEY, 0, 24.hours.ago.to_i)

View File

@ -5,7 +5,7 @@ module Jobs
class ReindexSearch < ::Jobs::Scheduled
every 2.hours
CLEANUP_GRACE_PERIOD ||= 1.day.ago
CLEANUP_GRACE_PERIOD = 1.day.ago
def execute(args)
@verbose = true if args && Hash === args && args[:verbose]

View File

@ -3,8 +3,9 @@
# Ensure that scheduled jobs are loaded before mini_scheduler is configured.
if Rails.env == "development" && Sidekiq.server?
require "jobs/base"
Dir.glob("#{Rails.root}/app/jobs/scheduled/*.rb") do |f|
load(f)
require(f)
end
end