Commit d419a59c authored by Henri Colas's avatar Henri Colas

Add ability to search in issue description and issue comments

 * edit queries in serach context
 * edit template for result
parent 186e8ad9
......@@ -24,7 +24,8 @@ class SearchContext
result[:blobs] = project.repository.search_files(query, params[:repository_ref]) unless project.empty_repo?
else
result[:merge_requests] = MergeRequest.in_projects(project_ids).search(query).order('updated_at DESC').limit(20)
result[:issues] = Issue.where(project_id: project_ids).search(query).order('updated_at DESC').limit(20)
result[:issues] = Issue.where(project_id: project_ids).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_ids).where("note like :query", query: "%#{query}%").order('updated_at DESC').limit(20)
result[:wiki_pages] = []
end
end
......@@ -34,6 +35,7 @@ class SearchContext
projects: [],
merge_requests: [],
issues: [],
notes: [],
wiki_pages: [],
blobs: []
}
......
......@@ -19,6 +19,7 @@ class SearchController < ApplicationController
@projects = result[:projects]
@merge_requests = result[:merge_requests]
@issues = result[:issues]
@notes = result[:notes]
@wiki_pages = result[:wiki_pages]
@blobs = Kaminari.paginate_array(result[:blobs]).page(params[:page]).per(20)
@total_results = @projects.count + @merge_requests.count + @issues.count + @wiki_pages.count + @blobs.total_count
......
......@@ -44,6 +44,17 @@
- if issue.closed?
%span.label Closed
- @notes.each do |note|
%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
- @wiki_pages.each do |wiki_page|
%li
wiki:
......
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