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

daily_build_group_report_result.rb « ci « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5dcf575abd706d13ae972d05ad7bbd4d11d06076 (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
31
32
33
# frozen_string_literal: true

module Ci
  class DailyBuildGroupReportResult < ApplicationRecord
    extend Gitlab::Ci::Model

    PARAM_TYPES = %w[coverage].freeze

    belongs_to :last_pipeline, class_name: 'Ci::Pipeline', foreign_key: :last_pipeline_id
    belongs_to :project
    belongs_to :group

    validates :data, json_schema: { filename: "daily_build_group_report_result_data" }

    scope :by_ref_path, -> (ref_path) { where(ref_path: ref_path) }
    scope :by_projects, -> (ids) { where(project_id: ids) }
    scope :by_group, -> (group_id) { where(group_id: group_id) }
    scope :with_coverage, -> { where("(data->'coverage') IS NOT NULL") }
    scope :with_default_branch, -> { where(default_branch: true) }
    scope :by_dates, -> (start_date, end_date) { where(date: start_date..end_date) }
    scope :ordered_by_date_and_group_name, -> { order(date: :desc, group_name: :asc) }

    store_accessor :data, :coverage

    class << self
      def upsert_reports(data)
        upsert_all(data, unique_by: :index_daily_build_group_report_results_unique_columns) if data.any?
      end
    end
  end
end

Ci::DailyBuildGroupReportResult.prepend_if_ee('EE::Ci::DailyBuildGroupReportResult')