Commit e07b2f527fcaff6f2a998b0a74b0669389fbbbe6
1 parent
02b310df
Exists in
spb-stable
and in
3 other branches
Fix global search
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
3 changed files
with
4 additions
and
1 deletions
Show diff stats
CHANGELOG
app/controllers/search_controller.rb
... | ... | @@ -7,6 +7,7 @@ class SearchController < ApplicationController |
7 | 7 | |
8 | 8 | if @project |
9 | 9 | return access_denied! unless can?(current_user, :download_code, @project) |
10 | + | |
10 | 11 | @search_results = Search::ProjectService.new(@project, current_user, params).execute |
11 | 12 | else |
12 | 13 | @search_results = Search::GlobalService.new(current_user, params).execute | ... | ... |
app/services/search/global_service.rb
... | ... | @@ -14,9 +14,10 @@ module Search |
14 | 14 | group = Group.find_by(id: params[:group_id]) if params[:group_id].present? |
15 | 15 | projects = Project.accessible_to(current_user) |
16 | 16 | projects = projects.where(namespace_id: group.id) if group |
17 | - projects = projects.search(query) | |
18 | 17 | project_ids = projects.pluck(:id) |
19 | 18 | |
19 | + projects = projects.search(query) | |
20 | + | |
20 | 21 | result[:projects] = projects.limit(20) |
21 | 22 | result[:merge_requests] = MergeRequest.in_projects(project_ids).search(query).order('updated_at DESC').limit(20) |
22 | 23 | result[:issues] = Issue.where(project_id: project_ids).search(query).order('updated_at DESC').limit(20) | ... | ... |