Commit 0fb4bdd9 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'mk/geo/fix-wiki-synced-and-verified-counts' into 'master'

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

Closes #5361

See merge request gitlab-org/gitlab-ee!5352
parents 46b5faf3 0e94654a
......@@ -159,7 +159,7 @@ module Geo
# @return [ActiveRecord::Relation<Geo::ProjectRegistry>]
def fdw_find_enabled_wikis
Geo::ProjectRegistry.synced_wikis.where(fdw_not_disabled_wikis)
Geo::ProjectRegistry.synced_wikis.where(fdw_enabled_wikis)
end
# @return [ActiveRecord::Relation<Geo::Fdw::Project>]
......@@ -189,7 +189,7 @@ module Geo
# @return [ActiveRecord::Relation<Geo::ProjectRegistry>]
def fdw_find_verified_wikis
Geo::ProjectRegistry.verified_wikis.where(fdw_not_disabled_wikis)
Geo::ProjectRegistry.verified_wikis.where(fdw_enabled_wikis)
end
def fdw_inner_join_repository_state
......@@ -199,14 +199,14 @@ module Geo
.join_sources
end
def fdw_not_disabled_wikis
def fdw_enabled_wikis
project_id_matcher =
Geo::Fdw::ProjectFeature.arel_table[:project_id]
.eq(Geo::ProjectRegistry.arel_table[:project_id])
# Only read the IDs of projects with disabled wikis from the remote database
Geo::Fdw::ProjectFeature
.where(wiki_access_level: [::ProjectFeature::DISABLED, nil])
.where(wiki_access_level: [::ProjectFeature::DISABLED])
.where(project_id_matcher)
.select('1')
.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
expect(subject.count_synced_wikis).to eq 1
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
before do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
......@@ -486,6 +494,14 @@ describe Geo::ProjectRegistryFinder, :geo do
expect(subject.count_synced_wikis).to eq 1
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
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