diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-02-15 13:23:39 +0000 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-02-28 10:46:20 +0000 |
commit | 335ee79a73fafdf00fac6e8ffc286ce4bad273ff (patch) | |
tree | d30033fd007c992448ce02f42e46f9da48e223cb /lib/gitlab/cycle_analytics/base_stage.rb | |
parent | 3f31da9c69c550d1698a1376e37d36f4e6e309b5 (diff) | |
download | gitlab-ce-335ee79a73fafdf00fac6e8ffc286ce4bad273ff.tar.gz |
Refactors median code to work with both single and multiple projects
Diffstat (limited to 'lib/gitlab/cycle_analytics/base_stage.rb')
-rw-r--r-- | lib/gitlab/cycle_analytics/base_stage.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/gitlab/cycle_analytics/base_stage.rb b/lib/gitlab/cycle_analytics/base_stage.rb index 45386fee622..5c3fd901f79 100644 --- a/lib/gitlab/cycle_analytics/base_stage.rb +++ b/lib/gitlab/cycle_analytics/base_stage.rb @@ -31,8 +31,12 @@ module Gitlab interval_query = Arel::Nodes::As.new(cte_table, subtract_datetimes(stage_query(project_ids), start_time_attrs, end_time_attrs, name.to_s)) - median_datetimes(cte_table, interval_query, name, :project_id)&.each do |project_id, median| - loader.call(project_id, median) + if project_ids.size == 1 + loader.call(@project.id, median_datetime(cte_table, interval_query, name)) + else + median_datetimes(cte_table, interval_query, name, :project_id)&.each do |project_id, median| + loader.call(project_id, median) + end end end end |