Commit 40b85ac2 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch '217706-fix-recorded_at-delay' into 'master'

Calculate recording time  before other usage data

See merge request gitlab-org/gitlab!33882
parents 503ad118 dd3927e3
......@@ -39,11 +39,9 @@ module EE
override :uncached_data
def uncached_data
usage_activity_by_stage_monthly = usage_activity_by_stage(:usage_activity_by_stage_monthly, default_time_period)
super
.merge(usage_activity_by_stage)
.merge(usage_activity_by_stage_monthly)
.merge(usage_activity_by_stage(:usage_activity_by_stage_monthly, default_time_period))
.merge(recording_ee_finish_data)
end
......
......@@ -45,7 +45,7 @@ module Gitlab
def license_usage_data
{
recorded_at: Time.now, # should be calculated very first
recorded_at: recorded_at,
uuid: alt_usage_data { Gitlab::CurrentSettings.uuid },
hostname: alt_usage_data { Gitlab.config.gitlab.host },
version: alt_usage_data { Gitlab::VERSION },
......@@ -55,6 +55,10 @@ module Gitlab
}
end
def recorded_at
Time.now
end
def recording_ce_finish_data
{
recording_ce_finished_at: Time.now
......
......@@ -10,6 +10,17 @@ describe Gitlab::UsageData, :aggregate_failures do
stub_object_store_settings
end
describe '#uncached_data' do
it 'ensures recorded_at is set before any other usage data calculation' do
%i(alt_usage_data redis_usage_data distinct_count count).each do |method|
expect(described_class).not_to receive(method)
end
expect(described_class).to receive(:recorded_at).and_raise(Exception.new('Stopped calculating recorded_at'))
expect { described_class.uncached_data }.to raise_error('Stopped calculating recorded_at')
end
end
describe '#data' do
let!(:ud) { build(:usage_data) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment