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:
authorHiroyuki Sato <sathiroyuki@gmail.com>2019-04-05 16:07:09 +0300
committerHiroyuki Sato <sathiroyuki@gmail.com>2019-04-05 16:47:20 +0300
commit770f721962cd30e930ab7b6e06e9386da6325c3c (patch)
treebcdfa840d1cf0d13694a0be828ac6bf758d11e72 /app/workers
parent074a1797fe581c8eb5cc65bd56af584d5c500688 (diff)
Refactor: extract duplicate steps to a service class
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/project_cache_worker.rb5
-rw-r--r--app/workers/update_project_statistics_worker.rb6
2 files changed, 3 insertions, 8 deletions
diff --git a/app/workers/project_cache_worker.rb b/app/workers/project_cache_worker.rb
index 5f4972d8f93..b2e0701008a 100644
--- a/app/workers/project_cache_worker.rb
+++ b/app/workers/project_cache_worker.rb
@@ -18,7 +18,7 @@ class ProjectCacheWorker
return unless project && project.repository.exists?
- update_statistics(project, statistics.map(&:to_sym))
+ update_statistics(project, statistics)
project.repository.refresh_method_caches(files.map(&:to_sym))
@@ -34,9 +34,8 @@ class ProjectCacheWorker
return if Gitlab::Database.read_only?
return unless try_obtain_lease_for(project.id, statistics)
- Rails.logger.info("Updating statistics for project #{project.id}")
+ Projects::UpdateStatisticsService.new(project, nil, statistics: statistics).execute
- project.statistics.refresh!(only: statistics)
UpdateProjectStatisticsWorker.perform_in(LEASE_TIMEOUT, project.id, statistics)
end
diff --git a/app/workers/update_project_statistics_worker.rb b/app/workers/update_project_statistics_worker.rb
index 46673c4b07e..9a29cc12707 100644
--- a/app/workers/update_project_statistics_worker.rb
+++ b/app/workers/update_project_statistics_worker.rb
@@ -12,11 +12,7 @@ class UpdateProjectStatisticsWorker
def perform(project_id, statistics = [])
project = Project.find_by(id: project_id)
- return unless project && project.repository.exists?
-
- Rails.logger.info("Updating statistics for project #{project.id}")
-
- project.statistics.refresh!(only: statistics.map(&:to_sym))
+ Projects::UpdateStatisticsService.new(project, nil, statistics: statistics).execute
end
# rubocop: enable CodeReuse/ActiveRecord
end