diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-08-03 09:13:39 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-08-03 09:13:39 +0300 |
commit | 85af3ea21a5a772cb22756190268ba3f921a6400 (patch) | |
tree | 4231bb48df2693c9600b5c5b7dabb9bae41c1d3e /app/services/ci | |
parent | 1f53cf7cf0cb53b5d69ab141fa9020356e62027e (diff) |
Added unique identifier to calculate_reactive_cache. Decoupled comparison logic to service. Fixed N+1 select queries.
Diffstat (limited to 'app/services/ci')
-rw-r--r-- | app/services/ci/compare_test_reports_service.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/services/ci/compare_test_reports_service.rb b/app/services/ci/compare_test_reports_service.rb new file mode 100644 index 00000000000..8bc3354c403 --- /dev/null +++ b/app/services/ci/compare_test_reports_service.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Ci + class CompareTestReportsService < ::BaseService + def execute(base_pipeline_iid, head_pipeline_iid) + base_pipeline = project.pipelines.find_by_iid(base_pipeline_iid) if base_pipeline_iid + head_pipeline = project.pipelines.find_by_iid(head_pipeline_iid) + + begin + comparer = Gitlab::Ci::Reports::TestReportsComparer + .new(base_pipeline&.test_reports, head_pipeline.test_reports) + + { + status: :parsed, + data: TestReportsComparerSerializer + .new(project: project) + .represent(comparer).to_json + } + rescue => e + { status: :error, status_reason: e.message } + end + end + end +end |