diff options
author | NotSqrt <notsqrt@gmail.com> | 2014-05-15 21:54:19 +0400 |
---|---|---|
committer | NotSqrt <notsqrt@gmail.com> | 2014-05-15 21:54:19 +0400 |
commit | 15e0ab498dc9f680dc6995c46a8ba7b76fc1f081 (patch) | |
tree | 70789affc23a2be89959eb9dec423c3d5affe858 | |
parent | 41ca07e6cb384a38dc629738ee4a7bf422e4e13a (diff) |
Update ability to search in issue descriptions and comments
-rw-r--r-- | app/services/search/global_service.rb | 1 | ||||
-rw-r--r-- | app/services/search/project_service.rb | 6 | ||||
-rw-r--r-- | app/views/search/_project_results.html.haml | 1 | ||||
-rw-r--r-- | app/views/search/results/_note.html.haml | 9 |
4 files changed, 15 insertions, 2 deletions
diff --git a/app/services/search/global_service.rb b/app/services/search/global_service.rb index 8a1fce17ce7..d4fb3598bf5 100644 --- a/app/services/search/global_service.rb +++ b/app/services/search/global_service.rb @@ -28,6 +28,7 @@ module Search projects: [], merge_requests: [], issues: [], + notes: [], total_results: 0, } end diff --git a/app/services/search/project_service.rb b/app/services/search/project_service.rb index 3ebaafc752c..493dee95f90 100644 --- a/app/services/search/project_service.rb +++ b/app/services/search/project_service.rb @@ -18,8 +18,9 @@ module Search result[:total_results] = blobs.total_count else result[:merge_requests] = project.merge_requests.search(query).order('updated_at DESC').limit(20) - result[:issues] = project.issues.search(query).order('updated_at DESC').limit(20) - result[:total_results] = %w(issues merge_requests).sum { |items| result[items.to_sym].size } + result[:issues] = project.issues.where("title like :query OR description like :query ", query: "%#{query}%").order('updated_at DESC').limit(20) + result[:notes] = Note.where(noteable_type: 'issue').where(project_id: project.id).where("note like :query", query: "%#{query}%").order('updated_at DESC').limit(20) + result[:total_results] = %w(issues merge_requests notes).sum { |items| result[items.to_sym].size } end result @@ -30,6 +31,7 @@ module Search merge_requests: [], issues: [], blobs: [], + notes: [], total_results: 0, } end diff --git a/app/views/search/_project_results.html.haml b/app/views/search/_project_results.html.haml index f285bda5736..af3b97879c7 100644 --- a/app/views/search/_project_results.html.haml +++ b/app/views/search/_project_results.html.haml @@ -15,3 +15,4 @@ %ul.bordered-list = render partial: "search/results/merge_request", collection: @search_results[:merge_requests] = render partial: "search/results/issue", collection: @search_results[:issues] + = render partial: "search/results/note", collection: @search_results[:notes] diff --git a/app/views/search/results/_note.html.haml b/app/views/search/results/_note.html.haml new file mode 100644 index 00000000000..97e892bdd4d --- /dev/null +++ b/app/views/search/results/_note.html.haml @@ -0,0 +1,9 @@ +%li + note on issue: + = link_to [note.project, note.noteable] do + %span ##{note.noteable.iid} + %strong.term + = truncate note.noteable.title, length: 50 + %span.light (#{note.project.name_with_namespace}) + - if note.noteable.closed? + %span.label Closed |