diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-08-26 16:18:52 +0530 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-08-26 16:28:20 +0530 |
commit | 331080bca683fdab73520f68c53f6a5367d17f22 (patch) | |
tree | 2aaf99f087b86c25fe7e0d25feb22f501437bdf9 /app/models/cycle_analytics.rb | |
parent | ce6bcdd0043caf267d5d4478d45741aa4ecf1ac9 (diff) | |
download | gitlab-ce-331080bca683fdab73520f68c53f6a5367d17f22.tar.gz |
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.
Diffstat (limited to 'app/models/cycle_analytics.rb')
-rw-r--r-- | app/models/cycle_analytics.rb | 19 |
1 files changed, 11 insertions, 8 deletions
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 |