summaryrefslogtreecommitdiff
path: root/app/finders
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-10-22 08:52:42 +0000
committerRémy Coutable <remy@rymai.me>2018-10-22 08:52:42 +0000
commit631f4e2f54290b539fa3a7bc928589b1949adc34 (patch)
treeb9da9af0823ab3a8ab618a61a60b1ee63f2af612 /app/finders
parent5b6007f995b60b938c65efe9a18ed4f2c7dafa4d (diff)
parent192ccaebfc09c29bc62defb5f9a0fc69600600a1 (diff)
downloadgitlab-ce-631f4e2f54290b539fa3a7bc928589b1949adc34.tar.gz
Merge branch '52559-applications-api-get-delete' into 'master'
Add Applications API endpoints for listing and deleting entries. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/52559 See merge request https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22296
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/applications_finder.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/finders/applications_finder.rb b/app/finders/applications_finder.rb
new file mode 100644
index 00000000000..3ded90f3fd5
--- /dev/null
+++ b/app/finders/applications_finder.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class ApplicationsFinder
+ attr_reader :params
+
+ def initialize(params = {})
+ @params = params
+ end
+
+ def execute
+ applications = Doorkeeper::Application.where(owner_id: nil) # rubocop: disable CodeReuse/ActiveRecord
+ by_id(applications)
+ end
+
+ private
+
+ def by_id(applications)
+ return applications unless params[:id]
+
+ Doorkeeper::Application.find_by(id: params[:id]) # rubocop: disable CodeReuse/ActiveRecord
+ end
+end