diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2018-09-24 13:23:15 +0000 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2018-09-24 13:23:15 +0000 |
commit | 28086b203ae397e01d5e9870dfbddd66466450c2 (patch) | |
tree | 43edb6f37f014be54dc5a6edc8726ea938d8959d /app | |
parent | 01426b03a57d0725e2792278a39ebdf642daac10 (diff) | |
parent | 9176ea999a96580358be9bbcd42403879c5ae707 (diff) | |
download | gitlab-ce-28086b203ae397e01d5e9870dfbddd66466450c2.tar.gz |
Merge branch 'dz-group-labels-finder' into 'master'
Move group labels AR code into finder
Closes #49653
See merge request gitlab-org/gitlab-ce!21854
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/groups/labels_controller.rb | 5 | ||||
-rw-r--r-- | app/finders/group_labels_finder.rb | 17 |
2 files changed, 18 insertions, 4 deletions
diff --git a/app/controllers/groups/labels_controller.rb b/app/controllers/groups/labels_controller.rb index 059cf160fa2..ae31313db64 100644 --- a/app/controllers/groups/labels_controller.rb +++ b/app/controllers/groups/labels_controller.rb @@ -10,10 +10,7 @@ class Groups::LabelsController < Groups::ApplicationController def index respond_to do |format| format.html do - @labels = @group.labels - .optionally_search(params[:search]) - .order_by(sort) - .page(params[:page]) + @labels = GroupLabelsFinder.new(@group, params.merge(sort: sort)).execute end format.json do render json: LabelSerializer.new.represent_appearance(available_labels) diff --git a/app/finders/group_labels_finder.rb b/app/finders/group_labels_finder.rb new file mode 100644 index 00000000000..903023033ed --- /dev/null +++ b/app/finders/group_labels_finder.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class GroupLabelsFinder + attr_reader :group, :params + + def initialize(group, params = {}) + @group = group + @params = params + end + + def execute + group.labels + .optionally_search(params[:search]) + .order_by(params[:sort]) + .page(params[:page]) + end +end |