mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
e1f293ad66
Removed sidetiq, introduced new scheduler - add basic UI - add schedule discover - add scheduling in initializer
33 lines
1.3 KiB
Ruby
33 lines
1.3 KiB
Ruby
require_dependency 'discourse_hub'
|
|
require_dependency 'discourse_updates'
|
|
|
|
module Jobs
|
|
class VersionCheck < Jobs::Scheduled
|
|
every 1.day
|
|
|
|
def execute(args)
|
|
if SiteSetting.version_checks? and (DiscourseUpdates.updated_at.nil? or DiscourseUpdates.updated_at < 1.minute.ago)
|
|
begin
|
|
prev_missing_versions_count = DiscourseUpdates.missing_versions_count || 0
|
|
|
|
json = DiscourseHub.discourse_version_check
|
|
DiscourseUpdates.last_installed_version = Discourse::VERSION::STRING
|
|
DiscourseUpdates.latest_version = json['latestVersion']
|
|
DiscourseUpdates.critical_updates_available = json['criticalUpdates']
|
|
DiscourseUpdates.missing_versions_count = json['missingVersionsCount']
|
|
DiscourseUpdates.updated_at = Time.zone.now
|
|
DiscourseUpdates.missing_versions = json['versions']
|
|
|
|
if SiteSetting.new_version_emails and json['missingVersionsCount'] > 0 and prev_missing_versions_count < json['missingVersionsCount'].to_i
|
|
message = VersionMailer.send_notice
|
|
Email::Sender.new(message, :new_version).send
|
|
end
|
|
rescue => e
|
|
raise e unless Rails.env == 'development' # Fail version check silently in development mode
|
|
end
|
|
end
|
|
true
|
|
end
|
|
|
|
end
|
|
end
|