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

daily_report_result_service.rb « ci « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 79b5015c076d1824494efbcfdbb0e33ea6371e41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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