Commit 69bad668 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'sh-revert-site-statistics-use' into 'master'

Geo: Revert use of SiteStatistic counters

See merge request gitlab-org/gitlab-ee!6793
parents c1848c64 05da8869
module Geo
class ProjectRegistryFinder < RegistryFinder
def count_repositories
if selective_sync?
# We need to count only the selected projects according to the sync rule
current_node.projects.count
else
# Counting whole table can be expensive, so we use a counter cache instead
SiteStatistic.fetch.repositories_count
end
current_node.projects.count
end
def count_wikis
if selective_sync?
# We need to count only withing the selected projects according to the sync rule
current_node.projects.with_wiki_enabled.count
else
# Counting whole table can be expensive, so we use a counter cache instead
SiteStatistic.fetch.wikis_count
end
current_node.projects.with_wiki_enabled.count
end
def count_synced_repositories
......
......@@ -25,54 +25,6 @@ describe Geo::ProjectRegistryFinder, :geo do
end
shared_examples 'counts all the things' do
describe '#count_repositories' do
context 'without selective sync' do
it 'returns cached count values' do
SiteStatistic.fetch.update(repositories_count: 222)
expect(subject.count_repositories).to eq(222)
end
end
context 'with selective sync' do
before do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
end
it 'returns only slice of selected repositories' do
create(:project, group: synced_group)
create(:project, group: synced_group)
create(:project)
expect(subject.count_repositories).to eq(2)
end
end
end
describe '#count_wikis' do
context 'without selective sync' do
it 'returns cached count values' do
SiteStatistic.fetch.update(wikis_count: 333)
expect(subject.count_wikis).to eq(333)
end
end
context 'with selective sync' do
before do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
end
it 'returns only slice of selected repositories' do
create(:project, group: synced_group)
create(:project, :wiki_disabled, group: synced_group)
create(:project)
expect(subject.count_wikis).to eq(1)
end
end
end
describe '#count_synced_repositories' do
it 'delegates to #find_synced_repositories' do
expect(subject).to receive(:find_synced_repositories).and_call_original
......
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