diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-18 12:09:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-18 12:09:31 +0300 |
commit | 6763d2787670bc03a36a8eb601703e88fc70dece (patch) | |
tree | edc653ffd3052e3f9898c4fa8a07621d51574767 /app/services | |
parent | ed9165c2abda1dca048a8d3cb8030d906c0bbb0c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/ci/daily_report_result_service.rb | 30 |
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 |