From bdfb349ff70f0fde6d4dc7b4317c3bc7ead580a4 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 5 Feb 2015 22:00:54 -0800 Subject: Refactor and improve sorting objects in API for projects, issues and merge requests --- lib/api/helpers.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib/api/helpers.rb') diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index be9e4280d65..8fa30460ba6 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -154,6 +154,22 @@ module API Gitlab::Access.options_with_owner.values.include? level.to_i end + def issuable_order_by + if params["order_by"] == 'updated_at' + 'updated_at' + else + 'created_at' + end + end + + def issuable_sort + if params["sort"] == 'asc' + :asc + else + :desc + end + end + # error helpers def forbidden!(reason = nil) -- cgit v1.2.1