mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 09:12:45 +08:00
Version checks: tolerate old version check data that can happen immediately after upgrading but forgetting to restart sidekiq/clockwork. Don't cache version check data along with other dashboard data.
This commit is contained in:
parent
fc25da09e3
commit
06140740d0
|
@ -4,6 +4,7 @@ class Admin::DashboardController < Admin::AdminController
|
|||
dashboard_data = Rails.cache.fetch("admin-dashboard-data-#{Discourse::VERSION::STRING}", expires_in: 1.hour) do
|
||||
AdminDashboardData.fetch_all.as_json
|
||||
end
|
||||
dashboard_data.merge!({version_check: DiscourseUpdates.check_version.as_json}) if SiteSetting.version_checks?
|
||||
render json: dashboard_data
|
||||
end
|
||||
|
||||
|
|
|
@ -59,9 +59,7 @@ class AdminDashboardData
|
|||
top_referrers: IncomingLinksReport.find('top_referrers').as_json,
|
||||
top_traffic_sources: IncomingLinksReport.find('top_traffic_sources').as_json,
|
||||
top_referred_topics: IncomingLinksReport.find('top_referred_topics').as_json
|
||||
}.merge(
|
||||
SiteSetting.version_checks? ? {version_check: DiscourseUpdates.check_version.as_json} : {}
|
||||
)
|
||||
}
|
||||
end
|
||||
|
||||
def rails_env_check
|
||||
|
|
|
@ -20,10 +20,19 @@ module DiscourseUpdates
|
|||
)
|
||||
end
|
||||
|
||||
if version_info.updated_at.nil? or
|
||||
(version_info.missing_versions_count == 0 and version_info.latest_version != version_info.installed_version)
|
||||
# Version check data is out of date.
|
||||
Jobs.enqueue(:version_check, all_sites: true)
|
||||
if SiteSetting.version_checks?
|
||||
|
||||
# Handle cases when version check data is old so we report something that makes sense
|
||||
|
||||
if (version_info.updated_at.nil? or
|
||||
(version_info.missing_versions_count == 0 and version_info.latest_version != version_info.installed_version) or
|
||||
(version_info.missing_versions_count != 0 and version_info.latest_version == version_info.installed_version))
|
||||
Jobs.enqueue(:version_check, all_sites: true)
|
||||
end
|
||||
|
||||
if !version_info.updated_at.nil? and version_info.latest_version == version_info.installed_version
|
||||
version_info.missing_versions_count = 0
|
||||
end
|
||||
end
|
||||
|
||||
version_info
|
||||
|
|
|
@ -5,7 +5,7 @@ module Jobs
|
|||
class VersionCheck < Jobs::Base
|
||||
|
||||
def execute(args)
|
||||
if SiteSetting.version_checks and (DiscourseUpdates.updated_at.nil? or DiscourseUpdates.updated_at < 1.minute.ago)
|
||||
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']
|
||||
|
|
|
@ -81,4 +81,28 @@ describe DiscourseUpdates do
|
|||
end
|
||||
end
|
||||
|
||||
context 'old version check data' do
|
||||
context 'installed is latest' do
|
||||
before { stub_data(Discourse::VERSION::STRING, 1, false, 8.hours.ago) }
|
||||
|
||||
it 'queues a version check' do
|
||||
Jobs.expects(:enqueue).with(:version_check, anything)
|
||||
subject
|
||||
end
|
||||
|
||||
it 'reports 0 missing versions' do
|
||||
subject['missing_versions_count'].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
context 'installed is not latest' do
|
||||
before { stub_data('0.9.1', 0, false, 8.hours.ago) }
|
||||
|
||||
it 'queues a version check' do
|
||||
Jobs.expects(:enqueue).with(:version_check, anything)
|
||||
subject
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user