diff options
author | Stephan van Leeuwen <stephan.vanleeuwen5@gmail.com> | 2014-12-19 21:26:19 +0300 |
---|---|---|
committer | Stephan van Leeuwen <stephan.vanleeuwen5@gmail.com> | 2014-12-29 18:36:56 +0300 |
commit | 6af34b0f71898f4a93473584a40cdea6e075e92b (patch) | |
tree | ab60d068cf21c58aaac207d0bff42c99623f5a41 /lib/api | |
parent | 6b507219465e50ceff726535f92b75fa9567906d (diff) |
Changed setting the sort variable
Changed from using cases to set the sort variable, to use a one line if/else statement
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/projects.rb | 24 |
1 files 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}") |