Commit 785fc194 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre Committed by Michael Kozono

Remove the Geo::Fdw::Project.search method

Since GitLab 13.2 we don't rely on FDW queries
to sync/verify these repositories.
parent 8e0c7cdf
......@@ -63,7 +63,9 @@ class Geo::DesignRegistry < Geo::BaseRegistry
#
# @param [String] query term that will search over :path, :name and :description
def self.with_search_by_project(query)
where(project: Geo::Fdw::Project.search(query))
return all if query.empty?
where(project_id: ::Project.search(query).limit(1000).pluck_primary_key)
end
def self.search(params)
......
......@@ -3,7 +3,6 @@
module Geo
module Fdw
class Project < ::Geo::BaseFdw
include Gitlab::SQL::Pattern
include Routable
self.primary_key = :id
......@@ -37,16 +36,6 @@ module Geo
end
class << self
# Searches for a list of projects based on the query given in `query`.
#
# On PostgreSQL this method uses "ILIKE" to perform a case-insensitive
# search.
#
# query - The search query as a String.
def search(query)
fuzzy_search(query, [:path, :name, :description])
end
def within_namespaces(namespace_ids)
where(arel_table.name => { namespace_id: namespace_ids })
end
......
......@@ -104,7 +104,9 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
#
# @param [String] query term that will search over :path, :name and :description
def self.with_search(query)
where(project: Geo::Fdw::Project.search(query))
return all if query.empty?
where(project_id: ::Project.search(query).limit(1000).pluck_primary_key)
end
def self.synced(type)
......
---
title: Geo - Admin Area > Geo > Projects/Designs search is limited to 1000 records
merge_request: 38347
author:
type: other
......@@ -16,7 +16,7 @@ RSpec.describe Geo::DesignRegistry, :geo do
let(:registry) { create(:geo_design_registry) }
end
describe '#search', :geo_fdw do
describe '#search' do
let!(:design_registry) { create(:geo_design_registry) }
let!(:failed_registry) { create(:geo_design_registry, :sync_failed) }
let!(:synced_registry) { create(:geo_design_registry, :synced) }
......
......@@ -6,45 +6,4 @@ RSpec.describe Geo::Fdw::Project, :geo_fdw, type: :model do
context 'relationships' do
it { is_expected.to have_many(:container_repositories).class_name('Geo::Fdw::ContainerRepository') }
end
describe '.search' do
let(:test_project) { create(:project, description: 'kitten mittens') }
let(:project) { described_class.find(test_project.id) }
it 'returns projects with a matching name' do
expect(described_class.search(project.name)).to eq([project])
end
it 'returns projects with a partially matching name' do
expect(described_class.search(project.name[0..2])).to eq([project])
end
it 'returns projects with a matching name regardless of the casing' do
expect(described_class.search(project.name.upcase)).to eq([project])
end
it 'returns projects with a matching description' do
expect(described_class.search(project.description)).to eq([project])
end
it 'returns projects with a partially matching description' do
expect(described_class.search('kitten')).to eq([project])
end
it 'returns projects with a matching description regardless of the casing' do
expect(described_class.search('KITTEN')).to eq([project])
end
it 'returns projects with a matching path' do
expect(described_class.search(project.path)).to eq([project])
end
it 'returns projects with a partially matching path' do
expect(described_class.search(project.path[0..2])).to eq([project])
end
it 'returns projects with a matching path regardless of the casing' do
expect(described_class.search(project.path.upcase)).to eq([project])
end
end
end
......@@ -2,12 +2,11 @@
require 'spec_helper'
RSpec.describe Geo::ProjectRegistry, :geo_fdw do
RSpec.describe Geo::ProjectRegistry, :geo do
include ::EE::GeoHelpers
using RSpec::Parameterized::TableSyntax
let(:project) { create(:project, description: 'kitten mittens') }
let(:registry) { create(:geo_project_registry, project_id: project.id) }
let(:registry) { create(:geo_project_registry) }
subject { registry }
......@@ -297,7 +296,10 @@ RSpec.describe Geo::ProjectRegistry, :geo_fdw do
end
end
describe '.with_search', :geo do
describe '.with_search' do
let_it_be(:project) { create(:project, description: 'kitten mittens') }
let_it_be(:registry) { create(:geo_project_registry, project_id: project.id) }
it 'returns project registries that refers to projects with a matching name' do
expect(described_class.with_search(project.name)).to eq([registry])
end
......@@ -365,6 +367,8 @@ RSpec.describe Geo::ProjectRegistry, :geo_fdw do
end
describe '.repository_replicated_for?' do
let_it_be(:project) { create(:project) }
context 'for a non-Geo setup' do
it 'returns true' do
expect(described_class.repository_replicated_for?(project.id)).to be_truthy
......@@ -514,7 +518,7 @@ RSpec.describe Geo::ProjectRegistry, :geo_fdw do
context 'with a number of syncs' do
it 'returns the number of syncs' do
2.times { Geo::ProjectHousekeepingService.new(project).increment! }
2.times { Geo::ProjectHousekeepingService.new(subject.project).increment! }
expect(subject.syncs_since_gc).to eq(2)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment