mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-24 08:09:13 -05:00
24 lines
No EOL
818 B
Ruby
24 lines
No EOL
818 B
Ruby
require_dependency 'discourse_hub'
|
|
require_dependency 'discourse_updates'
|
|
|
|
module Jobs
|
|
class VersionCheck < Jobs::Scheduled
|
|
recurrence { daily }
|
|
|
|
def execute(args)
|
|
if SiteSetting.version_checks? and (DiscourseUpdates.updated_at.nil? or DiscourseUpdates.updated_at < 1.minute.ago)
|
|
begin
|
|
json = DiscourseHub.discourse_version_check
|
|
DiscourseUpdates.latest_version = json['latestVersion']
|
|
DiscourseUpdates.critical_updates_available = json['criticalUpdates']
|
|
DiscourseUpdates.missing_versions_count = json['missingVersionsCount']
|
|
DiscourseUpdates.updated_at = Time.zone.now
|
|
rescue => e
|
|
raise e unless Rails.env == 'development' # Fail version check silently in development mode
|
|
end
|
|
end
|
|
true
|
|
end
|
|
|
|
end
|
|
end |