From 6af34b0f71898f4a93473584a40cdea6e075e92b Mon Sep 17 00:00:00 2001
From: Stephan van Leeuwen <stephan.vanleeuwen5@gmail.com>
Date: Fri, 19 Dec 2014 19:26:19 +0100
Subject: [PATCH] Changed setting the sort variable

Changed from using cases to set the sort variable, to use a one line if/else statement
---
 lib/api/projects.rb | 24 ++++--------------------
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index 2b6ec5e1b94..c5f57b9f8da 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -22,11 +22,7 @@ module API
       #   GET /projects
       get do
         @projects = current_user.authorized_projects
-
-        sort = case params["sort"]
-                 when 'desc' then 'DESC'
-                 else 'ASC'
-               end
+        sort = params[:sort] == 'desc' ? 'desc' : 'asc'
 
         @projects = case params["order_by"]
                       when 'id' then @projects.reorder("id #{sort}")
@@ -50,11 +46,7 @@ module API
       # Example Request:
       #   GET /projects/owned
       get '/owned' do
-        sort = case params["sort"]
-                 when 'desc' then 'DESC'
-                 else 'ASC'
-               end
-
+        sort = params[:sort] == 'desc' ? 'desc' : 'asc'
         @projects = current_user.owned_projects
         @projects = case params["order_by"]
                       when 'id' then @projects.reorder("id #{sort}")
@@ -74,11 +66,7 @@ module API
       #   GET /projects/all
       get '/all' do
         authenticated_as_admin!
-
-        sort = case params["sort"]
-                 when 'desc' then 'DESC'
-                 else 'ASC'
-               end
+        sort = params[:sort] == 'desc' ? 'desc' : 'asc'
 
         @projects = case params["order_by"]
                       when 'id' then Project.order("id #{sort}")
@@ -268,11 +256,7 @@ module API
         ids = current_user.authorized_projects.map(&:id)
         visibility_levels = [ Gitlab::VisibilityLevel::INTERNAL, Gitlab::VisibilityLevel::PUBLIC ]
         projects = Project.where("(id in (?) OR visibility_level in (?)) AND (name LIKE (?))", ids, visibility_levels, "%#{params[:query]}%")
-
-        sort = case params["sort"]
-                 when 'desc' then 'DESC'
-                 else 'ASC'
-               end
+        sort = params[:sort] == 'desc' ? 'desc' : 'asc'
 
         projects = case params["order_by"]
                      when 'id' then projects.order("id #{sort}")
-- 
2.30.9