diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-18 11:17:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-18 11:17:02 +0300 |
commit | b39512ed755239198a9c294b6a45e65c05900235 (patch) | |
tree | d234a3efade1de67c46b9e5a38ce813627726aa7 /app/workers/update_project_statistics_worker.rb | |
parent | d31474cf3b17ece37939d20082b07f6657cc79a9 (diff) |
Add latest changes from gitlab-org/gitlab@15-3-stable-eev15.3.0-rc42
Diffstat (limited to 'app/workers/update_project_statistics_worker.rb')
-rw-r--r-- | app/workers/update_project_statistics_worker.rb | 13 |
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 |