Remove GeoNode#filtered_project_registries

parent a8f67b5f
......@@ -145,17 +145,6 @@ class GeoNode < ActiveRecord::Base
projects.where(id: project_id).exists?
end
def filtered_project_registries(type = nil)
case type
when 'repository'
project_registries.failed_repos
when 'wiki'
project_registries.failed_wikis
else
project_registries.failed
end
end
def selective_sync?
namespaces.exists?
end
......
......@@ -22,6 +22,17 @@ module Geo
relation.count
end
def find_failed_project_registries(type = nil)
relation =
if selective_sync?
legacy_find_failed_project_registries(type)
else
find_failed_projects_registries(type)
end
relation
end
def find_unsynced_projects(batch_size:)
relation =
if fdw?
......@@ -50,8 +61,15 @@ module Geo
Geo::ProjectRegistry.synced
end
def find_failed_projects_registries
Geo::ProjectRegistry.failed
def find_failed_projects_registries(type = nil)
case type
when 'repository'
Geo::ProjectRegistry.failed_repos
when 'wiki'
Geo::ProjectRegistry.failed_wikis
else
Geo::ProjectRegistry.failed
end
end
#
......@@ -121,5 +139,19 @@ module Geo
joined_relation
end
def legacy_find_failed_project_registries(type)
project_registries = find_failed_projects_registries(type)
return Geo::ProjectRegistry.none if project_registries.empty?
joined_relation = project_registries.joins(<<~SQL)
INNER JOIN
(VALUES #{current_node.projects.pluck(:id).map { |id| "(#{id})" }.join(',')})
projects(project_id)
ON #{Geo::ProjectRegistry.table_name}.id = projects.project_id
SQL
joined_relation
end
end
end
......@@ -49,7 +49,8 @@ module API
not_found('Geo node not found') unless geo_node
project_registries = paginate(geo_node.filtered_project_registries(params[:type]))
finder = ::Geo::ProjectRegistryFinder.new(current_node: geo_node)
project_registries = paginate(finder.find_failed_project_registries(params[:type]))
present project_registries, with: ::GeoProjectRegistryEntity
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