diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-09-30 13:17:57 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-09-30 13:17:57 +0400 |
commit | 4c52ff51844f4c55e8c4a0f46a0b6aeacc7d42d5 (patch) | |
tree | f838215f9f04264e0325988f67823188e0bd46b6 /lib | |
parent | c20c2c83859bf7ba699c085a1baf0ee1f1a6da7a (diff) | |
parent | f258a59ef6156f9da3b527efe9088fd0708f6fdf (diff) |
Merge branch 'api/issues-filter-milestone' of https://github.com/jubianchi/gitlabhq into jubianchi-api/issues-filter-milestone
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Conflicts:
CHANGELOG
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/issues.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/api/issues.rb b/lib/api/issues.rb index 30170c657ba..d2828b24c36 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -4,7 +4,7 @@ module API before { authenticate! } helpers do - def filter_issues_state(issues, state = nil) + def filter_issues_state(issues, state) case state when 'opened' then issues.opened when 'closed' then issues.closed @@ -13,7 +13,11 @@ module API end def filter_issues_labels(issues, labels) - issues.includes(:labels).where("labels.title" => labels.split(',')) + issues.includes(:labels).where('labels.title' => labels.split(',')) + end + + def filter_issues_milestone(issues, milestone) + issues.includes(:milestone).where('milestones.title' => milestone) end end @@ -48,19 +52,24 @@ module API # id (required) - The ID of a project # state (optional) - Return "opened" or "closed" issues # labels (optional) - Comma-separated list of label names + # milestone (optional) - Milestone title # # Example Requests: # GET /projects/:id/issues # GET /projects/:id/issues?state=opened # GET /projects/:id/issues?state=closed - # GET /projects/:id/issues # GET /projects/:id/issues?labels=foo # GET /projects/:id/issues?labels=foo,bar # GET /projects/:id/issues?labels=foo,bar&state=opened + # GET /projects/:id/issues?milestone=1.0.0 + # GET /projects/:id/issues?milestone=1.0.0&state=closed get ":id/issues" do issues = user_project.issues issues = filter_issues_state(issues, params[:state]) unless params[:state].nil? issues = filter_issues_labels(issues, params[:labels]) unless params[:labels].nil? + unless params[:milestone].nil? + issues = filter_issues_milestone(issues, params[:milestone]) + end issues = issues.order('issues.id DESC') present paginate(issues), with: Entities::Issue |