From 5ae9a44aa17c8929627cc450f936cd960c143e25 Mon Sep 17 00:00:00 2001 From: Jacopo Date: Thu, 13 Dec 2018 20:26:56 +0100 Subject: Add project http fetch statistics API The API get projects/:id/traffic/fetches allows user with write access to the repository to get the number of clones for the last 30 days. --- app/workers/all_queues.yml | 1 + app/workers/project_daily_statistics_worker.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 app/workers/project_daily_statistics_worker.rb (limited to 'app/workers') diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml index d0fc130b04f..337f39b2091 100644 --- a/app/workers/all_queues.yml +++ b/app/workers/all_queues.yml @@ -146,3 +146,4 @@ - repository_cleanup - delete_stored_files - import_issues_csv +- project_daily_statistics diff --git a/app/workers/project_daily_statistics_worker.rb b/app/workers/project_daily_statistics_worker.rb new file mode 100644 index 00000000000..101f5c28459 --- /dev/null +++ b/app/workers/project_daily_statistics_worker.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class ProjectDailyStatisticsWorker + include ApplicationWorker + + def perform(project_id) + project = Project.find_by_id(project_id) + + return unless project&.repository&.exists? + + Projects::FetchStatisticsIncrementService.new(project).execute + end +end -- cgit v1.2.1