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)