From bfb067cd7a70f3a71b742518300f83c470467cf1 Mon Sep 17 00:00:00 2001 From: Alex Kriuchykhin Date: Thu, 6 Feb 2025 09:26:25 +0100 Subject: [PATCH] Fix global search for inventory items from shared inventories [SCI-11532] (#8212) --- app/controllers/search_controller.rb | 2 +- app/models/repository_row.rb | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 8280193e0..5623e71cc 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -114,7 +114,7 @@ class SearchController < ApplicationController return when 'repository_rows' @model = RepositoryRow - search_by_name(RepositoryRow) + search_by_name render json: @records, each_serializer: GlobalSearch::RepositoryRowSerializer, diff --git a/app/models/repository_row.rb b/app/models/repository_row.rb index 1e8c94ecd..396be8473 100644 --- a/app/models/repository_row.rb +++ b/app/models/repository_row.rb @@ -137,11 +137,7 @@ class RepositoryRow < ApplicationRecord teams = options[:teams] || current_team || user.teams.select(:id) searchable_row_fields = [RepositoryRow::PREFIXED_ID_SQL, 'repository_rows.name', 'users.full_name'] - readable_rows = - distinct - .joins(:repository, :created_by) - .where(repositories: { id: Repository.with_granted_permissions(user, RepositoryPermissions::READ).select(:id), - team_id: teams }) + readable_rows = distinct.joins(:repository, :created_by).viewable_by_user(user, teams) readable_rows = readable_rows.active unless include_archived repository_rows = readable_rows.where_attributes_like_boolean(searchable_row_fields, query, options)