diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /app/models/ci/build_report_result.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'app/models/ci/build_report_result.rb')
-rw-r--r-- | app/models/ci/build_report_result.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/app/models/ci/build_report_result.rb b/app/models/ci/build_report_result.rb new file mode 100644 index 00000000000..530233ad5c0 --- /dev/null +++ b/app/models/ci/build_report_result.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +module Ci + class BuildReportResult < ApplicationRecord + extend Gitlab::Ci::Model + + 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 tests_total + [tests_success, tests_failed, tests_errored, tests_skipped].sum + end + end +end |