diff options
author | Rémy Coutable <remy@rymai.me> | 2017-03-02 10:18:02 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-03-02 10:18:02 +0000 |
commit | 034c64968224caafaa3aec904359bf82cce36f7a (patch) | |
tree | c71e679bc09d443e48e87cec80cd5740082aadd2 /lib | |
parent | d4154195329b0a823848df8ceae144aebd6ccf6b (diff) | |
parent | 61baf3528d2f39ffc8f7aa07eddf3df0cec3508b (diff) | |
download | gitlab-ce-034c64968224caafaa3aec904359bf82cce36f7a.tar.gz |
Merge branch '28807-search-for-milestone-by-title-in-rest-api' into 'master'
Enable filtering milestones by search criteria in the API
Closes #28807
See merge request !9606
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/helpers.rb | 4 | ||||
-rw-r--r-- | lib/api/milestones.rb | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 72d2b320077..4600abc7dc7 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -164,6 +164,10 @@ module API items.where(iid: iid) end + def filter_by_search(items, text) + items.search(text) + end + # error helpers def forbidden!(reason = nil) diff --git a/lib/api/milestones.rb b/lib/api/milestones.rb index 0b4ed76b35c..44bdaea7fa4 100644 --- a/lib/api/milestones.rb +++ b/lib/api/milestones.rb @@ -31,6 +31,7 @@ module API optional :state, type: String, values: %w[active closed all], default: 'all', desc: 'Return "active", "closed", or "all" milestones' optional :iid, type: Array[Integer], desc: 'The IID of the milestone' + optional :search, type: String, desc: 'The search criteria for the title or description of the milestone' use :pagination end get ":id/milestones" do @@ -39,6 +40,7 @@ module API milestones = user_project.milestones milestones = filter_milestones_state(milestones, params[:state]) milestones = filter_by_iid(milestones, params[:iid]) if params[:iid].present? + milestones = filter_by_search(milestones, params[:search]) if params[:search] present paginate(milestones), with: Entities::Milestone end |