Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/workers/gitlab_usage_ping_worker.rb2
-rw-r--r--lib/gitlab/usage_data.rb8
-rw-r--r--spec/workers/gitlab_usage_ping_worker_spec.rb1
3 files changed, 6 insertions, 5 deletions
diff --git a/app/workers/gitlab_usage_ping_worker.rb b/app/workers/gitlab_usage_ping_worker.rb
index f26a3f47dad..4a9d626caec 100644
--- a/app/workers/gitlab_usage_ping_worker.rb
+++ b/app/workers/gitlab_usage_ping_worker.rb
@@ -15,7 +15,7 @@ class GitlabUsagePingWorker
begin
HTTParty.post(url,
- body: Gitlab::UsageData.to_json(true),
+ body: Gitlab::UsageData.to_json(force_refresh: true),
headers: { 'Content-type' => 'application/json' }
)
rescue HTTParty::Error => e
diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb
index 02750fa02e6..26812ed7164 100644
--- a/lib/gitlab/usage_data.rb
+++ b/lib/gitlab/usage_data.rb
@@ -3,16 +3,16 @@ module Gitlab
include Gitlab::CurrentSettings
class << self
- def data(force_refresh = false)
- Rails.cache.fetch('usage_data', force: force_refresh) { uncached_data }
+ def data(force_refresh: false)
+ Rails.cache.fetch('usage_data', force: force_refresh, expires_in: 2.weeks) { uncached_data }
end
def uncached_data
license_usage_data.merge(system_usage_data)
end
- def to_json(force_refresh = false)
- data(force_refresh).to_json
+ def to_json(force_refresh: false)
+ data(force_refresh: force_refresh).to_json
end
def system_usage_data
diff --git a/spec/workers/gitlab_usage_ping_worker_spec.rb b/spec/workers/gitlab_usage_ping_worker_spec.rb
index 8821df3d81e..b6c080f36f4 100644
--- a/spec/workers/gitlab_usage_ping_worker_spec.rb
+++ b/spec/workers/gitlab_usage_ping_worker_spec.rb
@@ -8,6 +8,7 @@ describe GitlabUsagePingWorker do
stub_request(:post, "https://version.gitlab.com/usage_data").
to_return(status: 200, body: '', headers: {})
+ expect(Gitlab::UsageData).to receive(:to_json).with({ force_refresh: true }).and_call_original
expect(subject).to receive(:try_obtain_lease).and_return(true)
expect(subject.perform.response.code.to_i).to eq(200)