Read about our upcoming Code of Conduct on this issue

list_issues_service.rb 857 Bytes
Newer Older
1
2
3
# frozen_string_literal: true

module ErrorTracking
4
  class ListIssuesService < ErrorTracking::BaseService
5
6
    DEFAULT_ISSUE_STATUS = 'unresolved'
    DEFAULT_LIMIT = 20
7
    DEFAULT_SORT = 'last_seen'
8

9
10
11
12
    def external_url
      project_error_tracking_setting&.sentry_external_url
    end

13
    private
14

15
16
17
18
19
20
21
22
23
24
    def fetch
      project_error_tracking_setting.list_sentry_issues(
        issue_status: issue_status,
        limit: limit,
        search_term: params[:search_term].presence,
        sort: sort,
        cursor: params[:cursor].presence
      )
    end

25
    def parse_response(response)
26
      response.slice(:issues, :pagination)
27
28
29
30
31
32
33
34
35
    end

    def issue_status
      params[:issue_status] || DEFAULT_ISSUE_STATUS
    end

    def limit
      params[:limit] || DEFAULT_LIMIT
    end
36

37
38
39
    def sort
      params[:sort] || DEFAULT_SORT
    end
40
41
  end
end