2012-03-15 19:14:39 -04:00
|
|
|
class SearchController < ApplicationController
|
|
|
|
def show
|
2013-01-25 03:07:21 -05:00
|
|
|
project_id = params[:project_id]
|
|
|
|
group_id = params[:group_id]
|
|
|
|
|
|
|
|
project_ids = current_user.authorized_projects.map(&:id)
|
|
|
|
|
|
|
|
if group_id.present?
|
2013-05-09 04:46:32 -04:00
|
|
|
@group = Group.find(group_id)
|
|
|
|
group_project_ids = @group.projects.map(&:id)
|
2013-01-25 03:07:21 -05:00
|
|
|
project_ids.select! { |id| group_project_ids.include?(id)}
|
|
|
|
elsif project_id.present?
|
2013-05-14 13:11:48 -04:00
|
|
|
@project = Project.find(params[:project_id])
|
2013-01-25 03:07:21 -05:00
|
|
|
project_ids.select! { |id| id == project_id.to_i}
|
|
|
|
end
|
|
|
|
|
|
|
|
result = SearchContext.new(project_ids, params).execute
|
2012-07-31 01:32:49 -04:00
|
|
|
|
2012-10-09 15:09:46 -04:00
|
|
|
@projects = result[:projects]
|
|
|
|
@merge_requests = result[:merge_requests]
|
|
|
|
@issues = result[:issues]
|
2012-10-16 15:05:11 -04:00
|
|
|
@wiki_pages = result[:wiki_pages]
|
2013-05-14 13:25:16 -04:00
|
|
|
@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
|
2012-03-15 19:14:39 -04:00
|
|
|
end
|
|
|
|
end
|