Welcome to mirror list, hosted at ThFree Co, Russian Federation.

errors_finder.rb « error_tracking « finders « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fb2d4b14dfae6f51fc96251116ccbc5d30db5174 (plain)
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
# frozen_string_literal: true

module ErrorTracking
  class ErrorsFinder
    def initialize(current_user, project, params)
      @current_user = current_user
      @project = project
      @params = params
    end

    def execute
      return ErrorTracking::Error.none unless authorized?

      collection = project.error_tracking_errors
      collection = by_status(collection)

      # Limit collection until pagination implemented
      collection.limit(20)
    end

    private

    attr_reader :current_user, :project, :params

    def by_status(collection)
      if params[:status].present? && ErrorTracking::Error.statuses.key?(params[:status])
        collection.for_status(params[:status])
      else
        collection
      end
    end

    def authorized?
      Ability.allowed?(current_user, :read_sentry_issue, project)
    end
  end
end