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:
authorStan Hu <stanhu@gmail.com>2016-10-05 01:32:02 +0300
committerRémy Coutable <remy@rymai.me>2017-04-14 16:20:55 +0300
commitbca368990acdb86acf251382c191fa9b7627837a (patch)
treea3718b38143ca1ddc2ccb8241a4696989a08f1fc
parentc53afeda0c2ee0cda89c235c9e8799baa1cfdc1a (diff)
Cache the last usage data to avoid unicorn timeouts
-rw-r--r--app/workers/gitlab_usage_ping_worker.rb2
-rw-r--r--lib/gitlab/usage_data.rb8
2 files changed, 5 insertions, 5 deletions
diff --git a/app/workers/gitlab_usage_ping_worker.rb b/app/workers/gitlab_usage_ping_worker.rb
index 866f5d03d8b..f26a3f47dad 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,
+ body: Gitlab::UsageData.to_json(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 46875908fa3..02750fa02e6 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
- Rails.cache.fetch('usage_data', expires_in: 1.hour) { uncached_data }
+ def data(force_refresh = false)
+ Rails.cache.fetch('usage_data', force: force_refresh) { uncached_data }
end
def uncached_data
license_usage_data.merge(system_usage_data)
end
- def to_json
- data.to_json
+ def to_json(force_refresh = false)
+ data(force_refresh).to_json
end
def system_usage_data