debian-mirror-gitlab/app/models/ci/daily_build_group_report_result.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
1.1 KiB
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
module Ci
2021-10-27 15:23:28 +05:30
class DailyBuildGroupReportResult < Ci::ApplicationRecord
2020-05-24 23:13:21 +05:30
PARAM_TYPES = %w[coverage].freeze
belongs_to :last_pipeline, class_name: 'Ci::Pipeline', foreign_key: :last_pipeline_id
belongs_to :project
2021-03-11 19:13:27 +05:30
belongs_to :group
2020-05-24 23:13:21 +05:30
2020-06-23 00:09:42 +05:30
validates :data, json_schema: { filename: "daily_build_group_report_result_data" }
2021-03-11 19:13:27 +05:30
scope :by_ref_path, -> (ref_path) { where(ref_path: ref_path) }
2021-01-29 00:20:46 +05:30
scope :by_projects, -> (ids) { where(project_id: ids) }
2021-03-11 19:13:27 +05:30
scope :by_group, -> (group_id) { where(group_id: group_id) }
2021-01-29 00:20:46 +05:30
scope :with_coverage, -> { where("(data->'coverage') IS NOT NULL") }
scope :with_default_branch, -> { where(default_branch: true) }
2021-03-11 19:13:27 +05:30
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) }
2020-11-24 15:15:51 +05:30
2021-01-29 00:20:46 +05:30
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
2020-05-24 23:13:21 +05:30
end
end
end
2021-01-29 00:20:46 +05:30
2021-06-08 01:23:25 +05:30
Ci::DailyBuildGroupReportResult.prepend_mod_with('Ci::DailyBuildGroupReportResult')