diff options
author | JB Vasseur <jvasseur@gmail.com> | 2018-10-15 23:03:08 +0900 |
---|---|---|
committer | JB Vasseur <jvasseur@gmail.com> | 2018-10-15 23:03:08 +0900 |
commit | 1ae9aefe5572cc62256f28e16163015f075b6c59 (patch) | |
tree | 0f9da6ffd350d58ce5e3085859222f7236d1e113 /app/finders | |
parent | c47aea75766fe3165cc9530fc9ccb5a4ac615e46 (diff) | |
download | gitlab-ce-1ae9aefe5572cc62256f28e16163015f075b6c59.tar.gz |
Use application finder for Doorkeeper Applications
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/applications_finder.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/finders/applications_finder.rb b/app/finders/applications_finder.rb new file mode 100644 index 00000000000..14bd35105d2 --- /dev/null +++ b/app/finders/applications_finder.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class ApplicationsFinder + attr_reader :params + + def initialize(params = {}) + @params = params + end + + # rubocop: disable CodeReuse/ActiveRecord + def execute + applications = Doorkeeper::Application.where("owner_id IS NULL") + by_id(applications) + end + # rubocop: enable CodeReuse/ActiveRecord + + private + + # rubocop: disable CodeReuse/ActiveRecord + def by_id(applications) + return applications unless params[:id] + + Doorkeeper::Application.find_by(id: params[:id]) + end + # rubocop: enable CodeReuse/ActiveRecord +end |