Remove GeoNode#uploads method

parent 3c86b1e1
......@@ -149,22 +149,6 @@ class GeoNode < ActiveRecord::Base
namespaces.exists?
end
def uploads
if selective_sync?
namespace_ids = Gitlab::GroupHierarchy.new(Gitlab::Geo.current_node.namespaces).base_and_descendants.select(:id)
project_ids = Gitlab::Geo.current_node.projects.select(:id)
uploads_table = Upload.arel_table
group_uploads = uploads_table[:model_type].eq('Namespace').and(uploads_table[:model_id].in(Arel::Nodes::SqlLiteral.new(namespace_ids.to_sql)))
project_uploads = uploads_table[:model_type].eq('Project').and(uploads_table[:model_id].in(Arel::Nodes::SqlLiteral.new(project_ids.to_sql)))
other_uploads = uploads_table[:model_type].not_in(%w[Namespace Project])
Upload.where(group_uploads.or(project_uploads).or(other_uploads))
else
Upload.all
end
end
def find_or_build_status
status || build_status
end
......
......@@ -65,7 +65,7 @@ class GeoNodeStatus < ActiveRecord::Base
self.last_event_date = latest_event&.created_at
self.repositories_count = geo_node.projects.count
self.lfs_objects_count = geo_node.lfs_objects.count
self.attachments_count = geo_node.uploads.count
self.attachments_count = attachments_finder.uploads.count
self.last_successful_status_check_at = Time.now
if Gitlab::Geo.secondary?
......
......@@ -22,8 +22,6 @@ module Geo
relation
end
private
def uploads
if selective_sync?
Upload.where(group_uploads.or(project_uploads).or(other_uploads))
......@@ -32,6 +30,8 @@ module Geo
end
end
private
def group_uploads
namespace_ids = Gitlab::GroupHierarchy.new(current_node.namespaces).base_and_descendants.select(:id)
arel_namespace_ids = Arel::Nodes::SqlLiteral.new(namespace_ids.to_sql)
......
......@@ -105,7 +105,7 @@ module Geo
registry_ids = legacy_pluck_registry_ids(file_types: Geo::FileService::DEFAULT_OBJECT_TYPES, except_registry_ids: except_registry_ids)
legacy_filter_registry_ids(
current_node.uploads,
attachments_finder.uploads,
registry_ids,
Upload.table_name
)
......@@ -132,5 +132,9 @@ module Geo
ids = Geo::FileRegistry.where(file_type: file_types).pluck(:file_id)
(ids + except_registry_ids).uniq
end
def attachments_finder
@attachments_finder ||= AttachmentRegistryFinder.new(current_node: current_node)
end
end
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