2012-10-09 21:09:46 +02:00
|
|
|
class SearchContext
|
|
|
|
attr_accessor :project_ids, :params
|
|
|
|
|
|
|
|
def initialize(project_ids, params)
|
|
|
|
@project_ids, @params = project_ids, params.dup
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
|
|
|
query = params[:search]
|
|
|
|
|
|
|
|
return result unless query.present?
|
|
|
|
|
|
|
|
result[:projects] = Project.where(id: project_ids).search(query).limit(10)
|
|
|
|
result[:merge_requests] = MergeRequest.where(project_id: project_ids).search(query).limit(10)
|
|
|
|
result[:issues] = Issue.where(project_id: project_ids).search(query).limit(10)
|
2012-10-16 21:05:11 +02:00
|
|
|
result[:wiki_pages] = Wiki.where(project_id: project_ids).search(query).limit(10)
|
2012-10-09 21:09:46 +02:00
|
|
|
result
|
|
|
|
end
|
|
|
|
|
|
|
|
def result
|
|
|
|
@result ||= {
|
|
|
|
projects: [],
|
|
|
|
merge_requests: [],
|
2012-10-16 21:05:11 +02:00
|
|
|
issues: [],
|
|
|
|
wiki_pages: []
|
2012-10-09 21:09:46 +02:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|