diff options
author | Hiroyuki Sato <sathiroyuki@gmail.com> | 2019-04-05 22:07:09 +0900 |
---|---|---|
committer | Hiroyuki Sato <sathiroyuki@gmail.com> | 2019-04-05 22:47:20 +0900 |
commit | 770f721962cd30e930ab7b6e06e9386da6325c3c (patch) | |
tree | bcdfa840d1cf0d13694a0be828ac6bf758d11e72 /app/services | |
parent | 074a1797fe581c8eb5cc65bd56af584d5c500688 (diff) | |
download | gitlab-ce-770f721962cd30e930ab7b6e06e9386da6325c3c.tar.gz |
Refactor: extract duplicate steps to a service class
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/projects/update_statistics_service.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/services/projects/update_statistics_service.rb b/app/services/projects/update_statistics_service.rb new file mode 100644 index 00000000000..f32a779fab0 --- /dev/null +++ b/app/services/projects/update_statistics_service.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Projects + class UpdateStatisticsService < BaseService + def execute + return unless project && project.repository.exists? + + Rails.logger.info("Updating statistics for project #{project.id}") + + project.statistics.refresh!(only: statistics.map(&:to_sym)) + end + + private + + def statistics + params[:statistics] + end + end +end |