summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-03 15:09:56 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-03 15:09:56 +0000
commitc08d9c22569d1c9e7c7737e183969593394133d9 (patch)
tree8ce1722f852f8921656080e04f6c9e16fa71ddb5 /app/services
parent546ddc3f6ac96fdf09934390a938bb391d07dc94 (diff)
downloadgitlab-ce-c08d9c22569d1c9e7c7737e183969593394133d9.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services')
-rw-r--r--app/services/ci/daily_report_result_service.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/app/services/ci/daily_report_result_service.rb b/app/services/ci/daily_report_result_service.rb
index 79b5015c076..b774a806203 100644
--- a/app/services/ci/daily_report_result_service.rb
+++ b/app/services/ci/daily_report_result_service.rb
@@ -19,12 +19,21 @@ module Ci
last_pipeline_id: pipeline.id
}
- pipeline.builds.with_coverage.map do |build|
+ aggregate(pipeline.builds.with_coverage).map do |group_name, group|
base_attrs.merge(
- title: build.group_name,
- value: build.coverage
+ title: group_name,
+ value: average_coverage(group)
)
end
end
+
+ def aggregate(builds)
+ builds.group_by(&:group_name)
+ end
+
+ def average_coverage(group)
+ total_coverage = group.reduce(0.0) { |sum, build| sum + build.coverage }
+ (total_coverage / group.size).round(2)
+ end
end
end