From 4531e433ad33e67cb66abaa4626b5e608eb11f11 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Mon, 19 Sep 2016 15:00:55 +0530 Subject: Make changes to the cycle analytics JSON endpoint. 1. Add `summary` section. 2. `stats` is `null` if no stats are present. 3. `stats` and `summary` are both arrays. --- app/models/cycle_analytics/summary.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 app/models/cycle_analytics/summary.rb (limited to 'app/models/cycle_analytics') diff --git a/app/models/cycle_analytics/summary.rb b/app/models/cycle_analytics/summary.rb new file mode 100644 index 00000000000..2fa94f8c18c --- /dev/null +++ b/app/models/cycle_analytics/summary.rb @@ -0,0 +1,21 @@ +class CycleAnalytics + class Summary + def initialize(project, from:) + @project = project + @from = from + end + + def new_issues + @project.issues.where("created_at > ?", @from).count + end + + def commits + repository = @project.repository.raw_repository + repository.log(ref: @project.default_branch, after: @from).count + end + + def deploys + @project.deployments.count + end + end +end -- cgit v1.2.1