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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/finders/error_tracking/errors_finder.rb')
-rw-r--r--app/finders/error_tracking/errors_finder.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/app/finders/error_tracking/errors_finder.rb b/app/finders/error_tracking/errors_finder.rb
new file mode 100644
index 00000000000..fb2d4b14dfa
--- /dev/null
+++ b/app/finders/error_tracking/errors_finder.rb
@@ -0,0 +1,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