Commit 502363a9 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch '13055-check-counters' into 'master'

Fix design counters for Geo Node status

Closes #13055

See merge request gitlab-org/gitlab!20173
parents 40ac9dc5 93ce9a07
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module Geo module Geo
class DesignRegistryFinder < RegistryFinder class DesignRegistryFinder < RegistryFinder
def count_syncable def count_syncable
designs_repositories.count GeoNode.find(current_node_id).projects.count_designs
end end
def count_synced def count_synced
...@@ -22,12 +22,10 @@ module Geo ...@@ -22,12 +22,10 @@ module Geo
private private
def designs_repositories
current_node.projects.inner_join_design_management
end
def registries def registries
designs_repositories current_node
.projects
.inner_join_design_management
.inner_join_design_registry .inner_join_design_registry
end end
end end
......
...@@ -191,6 +191,19 @@ module EE ...@@ -191,6 +191,19 @@ module EE
joins('LEFT JOIN services ON services.project_id = projects.id AND services.type = \'GitlabSlackApplicationService\' AND services.active IS true') joins('LEFT JOIN services ON services.project_id = projects.id AND services.type = \'GitlabSlackApplicationService\' AND services.active IS true')
.where('services.id IS NULL') .where('services.id IS NULL')
end end
def inner_join_design_management
join_statement =
arel_table
.join(DesignManagement::Design.arel_table, Arel::Nodes::InnerJoin)
.on(arel_table[:id].eq(DesignManagement::Design.arel_table[:project_id]))
joins(join_statement.join_sources)
end
def count_designs
inner_join_design_management.distinct.count
end
end end
def can_store_security_reports? def can_store_security_reports?
......
...@@ -21,7 +21,10 @@ describe Geo::DesignRegistryFinder, :geo, :geo_fdw do ...@@ -21,7 +21,10 @@ describe Geo::DesignRegistryFinder, :geo, :geo_fdw do
context 'count all the things' do context 'count all the things' do
describe '#count_syncable' do describe '#count_syncable' do
it 'returns number of container repositories' do it 'returns number of design repositories' do
# One more design for the same project to assert absence of duplicates
create(:design, project: synced_registry.project)
result = subject.count_syncable result = subject.count_syncable
expect(result).to eq(2) expect(result).to eq(2)
...@@ -67,7 +70,7 @@ describe Geo::DesignRegistryFinder, :geo, :geo_fdw do ...@@ -67,7 +70,7 @@ describe Geo::DesignRegistryFinder, :geo, :geo_fdw do
context 'count all the things' do context 'count all the things' do
describe '#count_syncable' do describe '#count_syncable' do
it 'returns number of container repositories' do it 'returns number of design repositories' do
result = subject.count_syncable result = subject.count_syncable
expect(result).to eq(2) expect(result).to eq(2)
......
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