Commit 15e0ab49 authored by NotSqrt's avatar NotSqrt

Update ability to search in issue descriptions and comments

parent 41ca07e6
...@@ -28,6 +28,7 @@ module Search ...@@ -28,6 +28,7 @@ module Search
projects: [], projects: [],
merge_requests: [], merge_requests: [],
issues: [], issues: [],
notes: [],
total_results: 0, total_results: 0,
} }
end end
......
...@@ -18,8 +18,9 @@ module Search ...@@ -18,8 +18,9 @@ module Search
result[:total_results] = blobs.total_count result[:total_results] = blobs.total_count
else else
result[:merge_requests] = project.merge_requests.search(query).order('updated_at DESC').limit(20) 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[:issues] = project.issues.where("title like :query OR description like :query ", query: "%#{query}%").order('updated_at DESC').limit(20)
result[:total_results] = %w(issues merge_requests).sum { |items| result[items.to_sym].size } 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 end
result result
...@@ -30,6 +31,7 @@ module Search ...@@ -30,6 +31,7 @@ module Search
merge_requests: [], merge_requests: [],
issues: [], issues: [],
blobs: [], blobs: [],
notes: [],
total_results: 0, total_results: 0,
} }
end end
......
...@@ -15,3 +15,4 @@ ...@@ -15,3 +15,4 @@
%ul.bordered-list %ul.bordered-list
= render partial: "search/results/merge_request", collection: @search_results[:merge_requests] = render partial: "search/results/merge_request", collection: @search_results[:merge_requests]
= render partial: "search/results/issue", collection: @search_results[:issues] = render partial: "search/results/issue", collection: @search_results[:issues]
= render partial: "search/results/note", collection: @search_results[:notes]
%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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment