Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-18 12:09:31 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-18 12:09:31 +0300
commit6763d2787670bc03a36a8eb601703e88fc70dece (patch)
treeedc653ffd3052e3f9898c4fa8a07621d51574767 /app/services
parented9165c2abda1dca048a8d3cb8030d906c0bbb0c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services')
-rw-r--r--app/services/ci/daily_report_result_service.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/app/services/ci/daily_report_result_service.rb b/app/services/ci/daily_report_result_service.rb
new file mode 100644
index 00000000000..79b5015c076
--- /dev/null
+++ b/app/services/ci/daily_report_result_service.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+module Ci
+ class DailyReportResultService
+ def execute(pipeline)
+ return unless Feature.enabled?(:ci_daily_code_coverage, pipeline.project, default_enabled: true)
+
+ DailyReportResult.upsert_reports(coverage_reports(pipeline))
+ end
+
+ private
+
+ def coverage_reports(pipeline)
+ base_attrs = {
+ project_id: pipeline.project_id,
+ ref_path: pipeline.source_ref_path,
+ param_type: DailyReportResult.param_types[:coverage],
+ date: pipeline.created_at.to_date,
+ last_pipeline_id: pipeline.id
+ }
+
+ pipeline.builds.with_coverage.map do |build|
+ base_attrs.merge(
+ title: build.group_name,
+ value: build.coverage
+ )
+ end
+ end
+ end
+end