diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2018-09-21 16:06:58 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2018-09-21 16:34:18 +0300 |
commit | 9176ea999a96580358be9bbcd42403879c5ae707 (patch) | |
tree | 33f9b50e0f85fbe11b79df8cf56ddfe8f8861ead /app | |
parent | e18d8d590b45daca41a1be39289fe29859504c09 (diff) | |
download | gitlab-ce-9176ea999a96580358be9bbcd42403879c5ae707.tar.gz |
Move group labels AR code into finderdz-group-labels-finder
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
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 |