File: issue_latest_event_service.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (41 lines) | stat: -rw-r--r-- 1,294 bytes parent folder | download
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
# frozen_string_literal: true

module ErrorTracking
  class IssueLatestEventService < ErrorTracking::BaseService
    private

    def perform
      response = find_issue_latest_event(params[:issue_id])

      compose_response(response)
    end

    def parse_response(response)
      { latest_event: response[:latest_event] }
    end

    def find_issue_latest_event(issue_id)
      # There are 2 types of the data source for the error tracking feature:
      #
      # * When integrated error tracking is enabled, we use the application database
      #   to read and save error tracking data.
      #
      # * When integrated error tracking is disabled we call
      #   project_error_tracking_setting method which works with Sentry API.
      #
      # Issue https://gitlab.com/gitlab-org/gitlab/-/issues/329596
      #
      if project_error_tracking_setting.integrated_client?
        handle_error_repository_exceptions do
          event = error_repository.last_event_for(issue_id)

          # We use the same response format as project_error_tracking_setting
          # method below for compatibility with existing code.
          { latest_event: event }
        end
      else
        project_error_tracking_setting.issue_latest_event(issue_id: issue_id)
      end
    end
  end
end