1# frozen_string_literal: true 2 3module Ci 4 # TODO: a couple of points with this approach: 5 # + reuses existing architecture and reactive caching 6 # - it's not a report comparison and some comparing features must be turned off. 7 # see CompareReportsBaseService for more notes. 8 # issue: https://gitlab.com/gitlab-org/gitlab/issues/34224 9 class GenerateExposedArtifactsReportService < CompareReportsBaseService 10 def execute(base_pipeline, head_pipeline) 11 data = FindExposedArtifactsService.new(project, current_user).for_pipeline(head_pipeline) 12 { 13 status: :parsed, 14 key: key(base_pipeline, head_pipeline), 15 data: data 16 } 17 rescue StandardError => e 18 Gitlab::ErrorTracking.track_exception(e, project_id: project.id) 19 { 20 status: :error, 21 key: key(base_pipeline, head_pipeline), 22 status_reason: _('An error occurred while fetching exposed artifacts.') 23 } 24 end 25 26 def latest?(base_pipeline, head_pipeline, data) 27 data&.fetch(:key, nil) == key(base_pipeline, head_pipeline) 28 end 29 end 30end 31