diff options
Diffstat (limited to 'lib/tasks/gitlab/refresh_project_statistics_build_artifacts_size.rake')
-rw-r--r-- | lib/tasks/gitlab/refresh_project_statistics_build_artifacts_size.rake | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/tasks/gitlab/refresh_project_statistics_build_artifacts_size.rake b/lib/tasks/gitlab/refresh_project_statistics_build_artifacts_size.rake index 203d500b616..9ed38a86bbd 100644 --- a/lib/tasks/gitlab/refresh_project_statistics_build_artifacts_size.rake +++ b/lib/tasks/gitlab/refresh_project_statistics_build_artifacts_size.rake @@ -1,19 +1,21 @@ # frozen_string_literal: true -require 'httparty' -require 'csv' - namespace :gitlab do - desc "GitLab | Refresh build artifacts size project statistics for given list of Project IDs from remote CSV" + desc "GitLab | Refresh build artifacts size project statistics for given list of Project IDs from CSV" BUILD_ARTIFACTS_SIZE_REFRESH_ENQUEUE_BATCH_SIZE = 500 - task :refresh_project_statistics_build_artifacts_size, [:csv_url] => :environment do |_t, args| - csv_url = args.csv_url + task :refresh_project_statistics_build_artifacts_size, [:csv_path] => :environment do |_t, args| + require 'httparty' + require 'csv' + + csv_path = args.csv_path - # rubocop: disable Gitlab/HTTParty - body = HTTParty.get(csv_url) - # rubocop: enable Gitlab/HTTParty + body = if csv_path.start_with?('http') + HTTParty.get(csv_path) # rubocop: disable Gitlab/HTTParty + else + File.read(csv_path) + end table = CSV.parse(body.to_s, headers: true) project_ids = table['PROJECT_ID'] |