diff --git a/CHANGELOG b/CHANGELOG index 6c8b4e6cd80..50cfc95ef33 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,7 @@ v 6.7.0 - Add retry feature for repository import - Reuse the GitLab LDAP connection within each request - Changed markdown new line behaviour to conform to markdown standards + - Fix global search v 6.6.2 diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index c1648d6c387..8df84e9884a 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -7,6 +7,7 @@ class SearchController < ApplicationController if @project return access_denied! unless can?(current_user, :download_code, @project) + @search_results = Search::ProjectService.new(@project, current_user, params).execute else @search_results = Search::GlobalService.new(current_user, params).execute diff --git a/app/services/search/global_service.rb b/app/services/search/global_service.rb index 09c7cb25dd5..372d1bf7129 100644 --- a/app/services/search/global_service.rb +++ b/app/services/search/global_service.rb @@ -14,9 +14,10 @@ module Search group = Group.find_by(id: params[:group_id]) if params[:group_id].present? projects = Project.accessible_to(current_user) projects = projects.where(namespace_id: group.id) if group - projects = projects.search(query) project_ids = projects.pluck(:id) + projects = projects.search(query) + result[:projects] = projects.limit(20) 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)