Commit 1fdbd1bc authored by Michael Kozono's avatar Michael Kozono

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

Remove FDW related code for project/wikis

Closes #223249

See merge request gitlab-org/gitlab!38417
parents 8c772ed1 2a9722cd
...@@ -123,12 +123,7 @@ module Geo::SelectiveSync ...@@ -123,12 +123,7 @@ module Geo::SelectiveSync
namespaces.arel_table namespaces.arel_table
end end
def project_model
raise NotImplementedError,
"#{self.class} does not implement #{__method__}"
end
def projects_table def projects_table
project_model.arel_table Project.arel_table
end end
end end
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
module Geo module Geo
module Fdw module Fdw
class GeoNode < ::Geo::BaseFdw class GeoNode < ::Geo::BaseFdw
include ::Geo::SelectiveSync
self.primary_key = :id self.primary_key = :id
self.inheritance_column = nil self.inheritance_column = nil
self.table_name = Gitlab::Geo::Fdw.foreign_table_name('geo_nodes') self.table_name = Gitlab::Geo::Fdw.foreign_table_name('geo_nodes')
...@@ -13,33 +11,6 @@ module Geo ...@@ -13,33 +11,6 @@ module Geo
has_many :geo_node_namespace_links, class_name: 'Geo::Fdw::GeoNodeNamespaceLink' has_many :geo_node_namespace_links, class_name: 'Geo::Fdw::GeoNodeNamespaceLink'
has_many :namespaces, class_name: 'Geo::Fdw::Namespace', through: :geo_node_namespace_links has_many :namespaces, class_name: 'Geo::Fdw::Namespace', through: :geo_node_namespace_links
def projects
return Geo::Fdw::Project.all unless selective_sync?
if selective_sync_by_namespaces?
projects_for_selected_namespaces
elsif selective_sync_by_shards?
projects_for_selected_shards
else
Geo::Fdw::Project.none
end
end
private
def projects_for_selected_namespaces
Geo::Fdw::Project
.within_namespaces(selected_namespaces_and_descendants.select(:id))
end
def projects_for_selected_shards
Geo::Fdw::Project.within_shards(selective_sync_shards)
end
def project_model
Geo::Fdw::Project
end
end end
end end
end end
# frozen_string_literal: true
module Geo
module Fdw
class Project < ::Geo::BaseFdw
include Routable
self.primary_key = :id
self.table_name = Gitlab::Geo::Fdw.foreign_table_name('projects')
belongs_to :namespace, class_name: 'Geo::Fdw::Namespace'
alias_method :parent, :namespace
class << self
def within_namespaces(namespace_ids)
where(arel_table.name => { namespace_id: namespace_ids })
end
def within_shards(shard_names)
where(repository_storage: Array(shard_names))
end
end
end
end
end
...@@ -409,8 +409,4 @@ class GeoNode < ApplicationRecord ...@@ -409,8 +409,4 @@ class GeoNode < ApplicationRecord
def projects_for_selected_shards def projects_for_selected_shards
Project.within_shards(selective_sync_shards) Project.within_shards(selective_sync_shards)
end end
def project_model
Project
end
end end
...@@ -3,42 +3,8 @@ ...@@ -3,42 +3,8 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Geo::Fdw::GeoNode, :geo, type: :model do RSpec.describe Geo::Fdw::GeoNode, :geo, type: :model do
let(:node) { create(:geo_node) }
let(:group_1) { create(:group) }
let(:group_2) { create(:group) }
let(:nested_group_1) { create(:group, parent: group_1) }
let(:project_1) { create(:project, group: group_1) }
let(:project_2) { create(:project, group: nested_group_1) }
let(:project_3) { create(:project, :broken_storage, group: group_2) }
context 'relationships' do context 'relationships' do
it { is_expected.to have_many(:geo_node_namespace_links).class_name('Geo::Fdw::GeoNodeNamespaceLink') } it { is_expected.to have_many(:geo_node_namespace_links).class_name('Geo::Fdw::GeoNodeNamespaceLink') }
it { is_expected.to have_many(:namespaces).class_name('Geo::Fdw::Namespace').through(:geo_node_namespace_links) } it { is_expected.to have_many(:namespaces).class_name('Geo::Fdw::Namespace').through(:geo_node_namespace_links) }
end end
describe '#projects', :geo_fdw do
subject { described_class.find(node.id) }
it 'returns all registries without selective sync' do
expect(subject.projects).to match_ids(project_1, project_2, project_3)
end
it 'returns projects that belong to the namespaces with selective sync by namespace' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.projects).to match_ids(project_1, project_2)
end
it 'returns projects that belong to the shards with selective sync by shard' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: %w[broken])
expect(subject.projects).to match_ids(project_3)
end
it 'returns nothing if an unrecognised selective sync type is used' do
node.update_attribute(:selective_sync_type, 'unknown')
expect(subject.projects).to be_empty
end
end
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