diff options
author | Shinya Maeda <gitlab.shinyamaeda@gmail.com> | 2017-03-08 21:05:33 +0900 |
---|---|---|
committer | Shinya Maeda <gitlab.shinyamaeda@gmail.com> | 2017-05-03 02:11:51 +0900 |
commit | 284cf0bfb5d56dd847e48b74b6ae6c2627e164d1 (patch) | |
tree | edc51b10b918c2121d885096c76fd73cbb4032f1 /app/finders | |
parent | 175800299bf497591e625e82fd71420644c0bc6b (diff) | |
download | gitlab-ce-284cf0bfb5d56dd847e48b74b6ae6c2627e164d1.tar.gz |
Add name. Improve order_and_sort.
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/pipelines_finder.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/app/finders/pipelines_finder.rb b/app/finders/pipelines_finder.rb index 10c8f5e0b2e..f6532377374 100644 --- a/app/finders/pipelines_finder.rb +++ b/app/finders/pipelines_finder.rb @@ -12,6 +12,7 @@ class PipelinesFinder items = by_scope(items) items = by_status(items) items = by_ref(items) + items = by_name(items) items = by_username(items) items = by_yaml_errors(items) order_and_sort(items) @@ -107,12 +108,16 @@ class PipelinesFinder end def order_and_sort(items) - if params[:order_by].present? && params[:sort].present? && - items.column_names.include?(params[:order_by]) && - params[:sort] =~ /\A(ASC|DESC)\z/i - items.reorder(params[:order_by] => params[:sort]) - else - items.reorder(id: :desc) - end + order_by = if params[:order_by].present? && items.column_names.include?(params[:order_by]) + params[:order_by] + else + :id + end + sort = if params[:sort].present? && params[:sort] =~ /\A(ASC|DESC)\z/i + params[:sort] + else + :desc + end + items.reorder(order_by => sort) end end |