diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-09-02 11:48:57 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-09-02 11:48:57 +0300 |
commit | 7e7f52862b2953f0b36a6fea37ca179e0182d0d8 (patch) | |
tree | 96cc47f8aea5c3254c12332257e169a816429485 /lib/api | |
parent | 6159ec565c4fae1b32e948b676cfe7993afe46e2 (diff) | |
parent | 4cfafd447515ee5c7b881fc46a345c181a6656e7 (diff) | |
download | gitlab-ce-7e7f52862b2953f0b36a6fea37ca179e0182d0d8.tar.gz |
Merge branch 'master' of github.com:gitlabhq/gitlabhq
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/issues.rb | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/lib/api/issues.rb b/lib/api/issues.rb index eb6a74cd2bc..299fd7e2399 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -3,13 +3,28 @@ module API class Issues < Grape::API before { authenticate! } + helpers do + def filter_issues_state(issues, state = nil) + case state + when 'opened' then issues.opened + when 'closed' then issues.closed + else issues + end + end + end + resource :issues do # Get currently authenticated user's issues # - # Example Request: + # Parameters: + # state (optional) - Return "opened" or "closed" issues + # + # Example Requests: # GET /issues + # GET /issues?state=opened + # GET /issues?state=closed get do - present paginate(current_user.issues), with: Entities::Issue + present paginate(filter_issues_state(current_user.issues, params['state'])), with: Entities::Issue end end @@ -18,10 +33,14 @@ module API # # Parameters: # id (required) - The ID of a project - # Example Request: + # state (optional) - Return "opened" or "closed" issues + # + # Example Requests: # GET /projects/:id/issues + # GET /projects/:id/issues?state=opened + # GET /projects/:id/issues?state=closed get ":id/issues" do - present paginate(user_project.issues), with: Entities::Issue + present paginate(filter_issues_state(user_project.issues, params['state'])), with: Entities::Issue end # Get a single project issue |