Commit e7cf10e4 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #5531 from NotSqrt/add-search

Add ability to search in issue description and issue comments
parents d7eb6e55 15e0ab49
......@@ -28,6 +28,7 @@ module Search
projects: [],
merge_requests: [],
issues: [],
notes: [],
total_results: 0,
}
end
......
......@@ -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
......
......@@ -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]
%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