summaryrefslogtreecommitdiff
path: root/app/finders
diff options
context:
space:
mode:
authorShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-02-28 21:24:49 +0900
committerShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-05-03 02:11:50 +0900
commit994e49b3fbc261f8e59429c1681d83c81ba25df3 (patch)
treec149ebe3247be8a074f4a2d5400874ec3ce3d9b8 /app/finders
parent01f6083939f8f9559f7e134f111bd40d17d357f9 (diff)
downloadgitlab-ce-994e49b3fbc261f8e59429c1681d83c81ba25df3.tar.gz
Fixed those points.
- username to user_id - Drop duration - Resolve comments - Add Changelog - Edit docs
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/pipelines_finder.rb27
1 files changed, 10 insertions, 17 deletions
diff --git a/app/finders/pipelines_finder.rb b/app/finders/pipelines_finder.rb
index 3a95a1eb2ae..c2e247a7ded 100644
--- a/app/finders/pipelines_finder.rb
+++ b/app/finders/pipelines_finder.rb
@@ -12,9 +12,8 @@ class PipelinesFinder
items = by_scope(items)
items = by_status(items)
items = by_ref(items)
- items = by_user(items)
- items = by_duration(items)
- items = by_yaml_error(items)
+ items = by_username(items)
+ items = by_yaml_errors(items)
order_and_sort(items)
end
@@ -80,24 +79,16 @@ class PipelinesFinder
end
end
- def by_user(items)
- if params[:user_id].present?
- items.where(user_id: params[:user_id])
+ def by_username(items)
+ if params[:username].present?
+ items.joins(:user).where("users.name = ?", params[:username])
else
items
end
end
- def by_duration(items)
- if params[:duration].present?
- items.where("duration > ?", params[:duration])
- else
- items
- end
- end
-
- def by_yaml_error(items)
- if params[:yaml_error].present? && params[:yaml_error]
+ def by_yaml_errors(items)
+ if params[:yaml_errors].present? && params[:yaml_errors]
items.where("yaml_errors IS NOT NULL")
else
items
@@ -105,7 +96,9 @@ class PipelinesFinder
end
def order_and_sort(items)
- if params[:order_by].present? && params[:sort].present?
+ if params[:order_by].present? && params[:sort].present? &&
+ items.column_names.include?(params[:order_by]) &&
+ (params[:sort].downcase == 'asc' || params[:sort].downcase == 'desc')
items.order("#{params[:order_by]} #{params[:sort]}")
else
items.order(id: :desc)