Commit 9fd1cdc4 authored by Michael Kozono's avatar Michael Kozono

Merge branch '223249-remove-geo-fdw-project-search' into 'master'

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

See merge request gitlab-org/gitlab!38347
parents 19c8ef03 785fc194
...@@ -63,7 +63,9 @@ class Geo::DesignRegistry < Geo::BaseRegistry ...@@ -63,7 +63,9 @@ class Geo::DesignRegistry < Geo::BaseRegistry
# #
# @param [String] query term that will search over :path, :name and :description # @param [String] query term that will search over :path, :name and :description
def self.with_search_by_project(query) 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 end
def self.search(params) def self.search(params)
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
module Geo module Geo
module Fdw module Fdw
class Project < ::Geo::BaseFdw class Project < ::Geo::BaseFdw
include Gitlab::SQL::Pattern
include Routable include Routable
self.primary_key = :id self.primary_key = :id
...@@ -16,16 +15,6 @@ module Geo ...@@ -16,16 +15,6 @@ module Geo
alias_method :parent, :namespace alias_method :parent, :namespace
class << self 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) def within_namespaces(namespace_ids)
where(arel_table.name => { namespace_id: namespace_ids }) where(arel_table.name => { namespace_id: namespace_ids })
end end
......
...@@ -104,7 +104,9 @@ class Geo::ProjectRegistry < Geo::BaseRegistry ...@@ -104,7 +104,9 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
# #
# @param [String] query term that will search over :path, :name and :description # @param [String] query term that will search over :path, :name and :description
def self.with_search(query) 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 end
def self.synced(type) 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 ...@@ -16,7 +16,7 @@ RSpec.describe Geo::DesignRegistry, :geo do
let(:registry) { create(:geo_design_registry) } let(:registry) { create(:geo_design_registry) }
end end
describe '#search', :geo_fdw do describe '#search' do
let!(:design_registry) { create(:geo_design_registry) } let!(:design_registry) { create(:geo_design_registry) }
let!(:failed_registry) { create(:geo_design_registry, :sync_failed) } let!(:failed_registry) { create(:geo_design_registry, :sync_failed) }
let!(:synced_registry) { create(:geo_design_registry, :synced) } let!(:synced_registry) { create(:geo_design_registry, :synced) }
......
...@@ -6,45 +6,4 @@ RSpec.describe Geo::Fdw::Project, :geo_fdw, type: :model do ...@@ -6,45 +6,4 @@ RSpec.describe Geo::Fdw::Project, :geo_fdw, type: :model do
context 'relationships' do context 'relationships' do
it { is_expected.to have_many(:container_repositories).class_name('Geo::Fdw::ContainerRepository') } it { is_expected.to have_many(:container_repositories).class_name('Geo::Fdw::ContainerRepository') }
end 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 end
...@@ -2,12 +2,11 @@ ...@@ -2,12 +2,11 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Geo::ProjectRegistry, :geo_fdw do RSpec.describe Geo::ProjectRegistry, :geo do
include ::EE::GeoHelpers include ::EE::GeoHelpers
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
let(:project) { create(:project, description: 'kitten mittens') } let(:registry) { create(:geo_project_registry) }
let(:registry) { create(:geo_project_registry, project_id: project.id) }
subject { registry } subject { registry }
...@@ -297,7 +296,10 @@ RSpec.describe Geo::ProjectRegistry, :geo_fdw do ...@@ -297,7 +296,10 @@ RSpec.describe Geo::ProjectRegistry, :geo_fdw do
end end
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 it 'returns project registries that refers to projects with a matching name' do
expect(described_class.with_search(project.name)).to eq([registry]) expect(described_class.with_search(project.name)).to eq([registry])
end end
...@@ -365,6 +367,8 @@ RSpec.describe Geo::ProjectRegistry, :geo_fdw do ...@@ -365,6 +367,8 @@ RSpec.describe Geo::ProjectRegistry, :geo_fdw do
end end
describe '.repository_replicated_for?' do describe '.repository_replicated_for?' do
let_it_be(:project) { create(:project) }
context 'for a non-Geo setup' do context 'for a non-Geo setup' do
it 'returns true' do it 'returns true' do
expect(described_class.repository_replicated_for?(project.id)).to be_truthy expect(described_class.repository_replicated_for?(project.id)).to be_truthy
...@@ -514,7 +518,7 @@ RSpec.describe Geo::ProjectRegistry, :geo_fdw do ...@@ -514,7 +518,7 @@ RSpec.describe Geo::ProjectRegistry, :geo_fdw do
context 'with a number of syncs' do context 'with a number of syncs' do
it 'returns the 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) expect(subject.syncs_since_gc).to eq(2)
end 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