From e64589a370c9536f8701c4b7124242b2d1016ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Fri, 22 Mar 2019 13:10:38 +0100 Subject: Refresh commit count after repository head changes --- app/models/project.rb | 1 + app/workers/project_cache_worker.rb | 1 + 2 files changed, 2 insertions(+) (limited to 'app') diff --git a/app/models/project.rb b/app/models/project.rb index 4cc13f372c1..7f052079e32 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1378,6 +1378,7 @@ class Project < ActiveRecord::Base repository.raw_repository.write_ref('HEAD', "refs/heads/#{branch}") repository.copy_gitattributes(branch) repository.after_change_head + ProjectCacheWorker.perform_async(self.id, [], [:commit_count]) reload_default_branch else errors.add(:base, "Could not change HEAD: branch '#{branch}' does not exist") diff --git a/app/workers/project_cache_worker.rb b/app/workers/project_cache_worker.rb index d27b5e62574..b31099bc670 100644 --- a/app/workers/project_cache_worker.rb +++ b/app/workers/project_cache_worker.rb @@ -27,6 +27,7 @@ class ProjectCacheWorker # rubocop: enable CodeReuse/ActiveRecord def update_statistics(project, statistics = []) + return if Gitlab::Database.read_only? return unless try_obtain_lease_for(project.id, :update_statistics) Rails.logger.info("Updating statistics for project #{project.id}") -- cgit v1.2.1