From 331080bca683fdab73520f68c53f6a5367d17f22 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Fri, 26 Aug 2016 16:18:52 +0530 Subject: Fetch cycle analytics data for a specific date range. 1. Supported date ranges are 30 / 90 days ago. The default is 90 days ago. 2. All issues created before "x days ago" are filtered out, even if they have other related data (test runs, merge requests) within the filter range. --- app/models/cycle_analytics.rb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'app/models/cycle_analytics.rb') diff --git a/app/models/cycle_analytics.rb b/app/models/cycle_analytics.rb index 331bb450e08..d6a0b5fcc7a 100644 --- a/app/models/cycle_analytics.rb +++ b/app/models/cycle_analytics.rb @@ -1,46 +1,49 @@ class CycleAnalytics - def initialize(project) + attr_reader :from + + def initialize(project, from:) @project = project + @from = from end def issue - calculate_metric(Queries::issues(@project), + calculate_metric(Queries::issues(@project, created_after: @from), -> (data_point) { data_point[:issue].created_at }, [Queries::issue_first_associated_with_milestone_at, Queries::issue_first_added_to_list_label_at]) end def plan - calculate_metric(Queries::issues(@project), + calculate_metric(Queries::issues(@project, created_after: @from), [Queries::issue_first_associated_with_milestone_at, Queries::issue_first_added_to_list_label_at], Queries::issue_closing_merge_request_opened_at) end def code - calculate_metric(Queries::merge_requests_closing_issues(@project), + calculate_metric(Queries::merge_requests_closing_issues(@project, created_after: @from), -> (data_point) { data_point[:merge_request].created_at }, [Queries::merge_request_first_assigned_to_user_other_than_author_at, Queries::merge_request_wip_flag_first_removed_at]) end def test - calculate_metric(Queries::merge_requests_closing_issues(@project), + calculate_metric(Queries::merge_requests_closing_issues(@project, created_after: @from), Queries::merge_request_build_started_at, Queries::merge_request_build_finished_at) end def review - calculate_metric(Queries::merge_requests_closing_issues(@project), + calculate_metric(Queries::merge_requests_closing_issues(@project, created_after: @from), [Queries::merge_request_first_assigned_to_user_other_than_author_at, Queries::merge_request_wip_flag_first_removed_at], [Queries::merge_request_first_closed_at, Queries::merge_request_merged_at]) end def staging - calculate_metric(Queries::merge_requests_closing_issues(@project), + calculate_metric(Queries::merge_requests_closing_issues(@project, created_after: @from), Queries::merge_request_merged_at, Queries::merge_request_deployed_to_any_environment_at) end def production - calculate_metric(Queries::merge_requests_closing_issues(@project), + calculate_metric(Queries::merge_requests_closing_issues(@project, created_after: @from), -> (data_point) { data_point[:issue].created_at }, Queries::merge_request_deployed_to_production_at) end -- cgit v1.2.1