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/finders/projects/daily_statistics_finder.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 app/finders/projects/daily_statistics_finder.rb (limited to 'app/finders') diff --git a/app/finders/projects/daily_statistics_finder.rb b/app/finders/projects/daily_statistics_finder.rb new file mode 100644 index 00000000000..912c23107bc --- /dev/null +++ b/app/finders/projects/daily_statistics_finder.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Projects + class DailyStatisticsFinder + attr_reader :project + + def initialize(project) + @project = project + end + + def fetches + ProjectDailyStatistic.of_project(project) + .of_last_30_days + .sorted_by_date_desc + end + + def total_fetch_count + fetches.sum_fetch_count + end + end +end -- cgit v1.2.3