summaryrefslogtreecommitdiff
path: root/app/models/ci/build_report_result.rb
blob: b674c1b1a0ee9a17bed3addbdfd92a7d879387c3 (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
34
35
36
37
38
39
40
41
42
43
# frozen_string_literal: true

module Ci
  class BuildReportResult < Ci::ApplicationRecord
    self.primary_key = :build_id

    belongs_to :build, class_name: "Ci::Build", inverse_of: :report_results
    belongs_to :project, class_name: "Project", inverse_of: :build_report_results

    validates :build, :project, presence: true
    validates :data, json_schema: { filename: "build_report_result_data" }

    store_accessor :data, :tests

    def tests_name
      tests.dig("name")
    end

    def tests_duration
      tests.dig("duration")
    end

    def tests_success
      tests.dig("success").to_i
    end

    def tests_failed
      tests.dig("failed").to_i
    end

    def tests_errored
      tests.dig("errored").to_i
    end

    def tests_skipped
      tests.dig("skipped").to_i
    end

    def suite_error
      tests.dig("suite_error")
    end
  end
end