diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-02-05 22:00:54 -0800 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-02-05 22:00:54 -0800 |
commit | bdfb349ff70f0fde6d4dc7b4317c3bc7ead580a4 (patch) | |
tree | b9e838d5a4d371a95ba0a957cee8c05da74818e9 /lib/api/helpers.rb | |
parent | 8952fc015fae476a20051c01cf4217d82d30c83d (diff) | |
download | gitlab-ce-bdfb349ff70f0fde6d4dc7b4317c3bc7ead580a4.tar.gz |
Refactor and improve sorting objects in API for projects, issues and merge requests
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r-- | lib/api/helpers.rb | 16 |
1 files changed, 16 insertions, 0 deletions
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) |