Commit 0e94654a authored by Michael Kozono's avatar Michael Kozono Committed by Nick Thomas

Geo: Fix enabled wiki counts with FDW enabled (impacts synced, out-of-sync,...

Geo: Fix enabled wiki counts with FDW enabled (impacts synced, out-of-sync, and verified wiki counts)
parent 46b5faf3
...@@ -159,7 +159,7 @@ module Geo ...@@ -159,7 +159,7 @@ module Geo
# @return [ActiveRecord::Relation<Geo::ProjectRegistry>] # @return [ActiveRecord::Relation<Geo::ProjectRegistry>]
def fdw_find_enabled_wikis def fdw_find_enabled_wikis
Geo::ProjectRegistry.synced_wikis.where(fdw_not_disabled_wikis) Geo::ProjectRegistry.synced_wikis.where(fdw_enabled_wikis)
end end
# @return [ActiveRecord::Relation<Geo::Fdw::Project>] # @return [ActiveRecord::Relation<Geo::Fdw::Project>]
...@@ -189,7 +189,7 @@ module Geo ...@@ -189,7 +189,7 @@ module Geo
# @return [ActiveRecord::Relation<Geo::ProjectRegistry>] # @return [ActiveRecord::Relation<Geo::ProjectRegistry>]
def fdw_find_verified_wikis def fdw_find_verified_wikis
Geo::ProjectRegistry.verified_wikis.where(fdw_not_disabled_wikis) Geo::ProjectRegistry.verified_wikis.where(fdw_enabled_wikis)
end end
def fdw_inner_join_repository_state def fdw_inner_join_repository_state
...@@ -199,14 +199,14 @@ module Geo ...@@ -199,14 +199,14 @@ module Geo
.join_sources .join_sources
end end
def fdw_not_disabled_wikis def fdw_enabled_wikis
project_id_matcher = project_id_matcher =
Geo::Fdw::ProjectFeature.arel_table[:project_id] Geo::Fdw::ProjectFeature.arel_table[:project_id]
.eq(Geo::ProjectRegistry.arel_table[:project_id]) .eq(Geo::ProjectRegistry.arel_table[:project_id])
# Only read the IDs of projects with disabled wikis from the remote database # Only read the IDs of projects with disabled wikis from the remote database
Geo::Fdw::ProjectFeature Geo::Fdw::ProjectFeature
.where(wiki_access_level: [::ProjectFeature::DISABLED, nil]) .where(wiki_access_level: [::ProjectFeature::DISABLED])
.where(project_id_matcher) .where(project_id_matcher)
.select('1') .select('1')
.exists .exists
......
---
title: 'Geo: Fix enabled wiki counts with FDW (impacts synced and verified counts)'
merge_request: 5352
author:
type: fixed
...@@ -87,6 +87,14 @@ describe Geo::ProjectRegistryFinder, :geo do ...@@ -87,6 +87,14 @@ describe Geo::ProjectRegistryFinder, :geo do
expect(subject.count_synced_wikis).to eq 1 expect(subject.count_synced_wikis).to eq 1
end end
it 'counts synced wikis with nil wiki_access_level (which means enabled wiki)' do
project_synced.project_feature.update!(wiki_access_level: nil)
create(:geo_project_registry, :synced, project: project_synced)
expect(subject.count_synced_wikis).to eq 1
end
context 'with selective sync' do context 'with selective sync' do
before do before do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group]) secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
...@@ -486,6 +494,14 @@ describe Geo::ProjectRegistryFinder, :geo do ...@@ -486,6 +494,14 @@ describe Geo::ProjectRegistryFinder, :geo do
expect(subject.count_synced_wikis).to eq 1 expect(subject.count_synced_wikis).to eq 1
end end
it 'counts synced wikis with nil wiki_access_level (which means enabled wiki)' do
project_synced.project_feature.update!(wiki_access_level: nil)
create(:geo_project_registry, :synced, project: project_synced)
expect(subject.count_synced_wikis).to eq 1
end
end end
describe '#fdw_find_verified_wikis' do describe '#fdw_find_verified_wikis' do
......
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