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:
Diffstat (limited to 'app/workers/update_project_statistics_worker.rb')
-rw-r--r--app/workers/update_project_statistics_worker.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/workers/update_project_statistics_worker.rb b/app/workers/update_project_statistics_worker.rb
index 45a6cc8f476..3308fa149f5 100644
--- a/app/workers/update_project_statistics_worker.rb
+++ b/app/workers/update_project_statistics_worker.rb
@@ -10,10 +10,15 @@ class UpdateProjectStatisticsWorker # rubocop:disable Scalability/IdempotentWork
feature_category :source_code_management
- # project_id - The ID of the project for which to flush the cache.
- # statistics - An Array containing columns from ProjectStatistics to
- # refresh, if empty all columns will be refreshed
- def perform(project_id, statistics = [])
+ # lease_key - The exclusive lease key to take
+ # project_id - The ID of the project for which to flush the cache.
+ # statistics - An Array containing columns from ProjectStatistics to
+ # refresh, if empty all columns will be refreshed
+ def perform(lease_key, project_id, statistics = [])
+ return unless Gitlab::ExclusiveLease
+ .new(lease_key, timeout: ProjectCacheWorker::LEASE_TIMEOUT)
+ .try_obtain
+
project = Project.find_by_id(project_id)
Projects::UpdateStatisticsService.new(project, nil, statistics: statistics).execute