GeoNodeStatus calculates numbers inefficiently
attachments_synced_count
In particular, there are a number of giant cross-database plucks that will need to be replaced with postgres_fdw when that is ready, but also consider this fragment:
def attachments_synced_count
@attachments_synced_count ||= begin
upload_ids = attachments.pluck(:id)
synced_ids = Geo::FileRegistry.where(file_type: [:attachment, :avatar, :file]).pluck(:file_id)
(synced_ids & upload_ids).length
end
end
I think this could just be Geo::FileRegistry.where(file_type: [:attachment, :avatar, :file]).count
Also, a bug: we need this is fixed in https://gitlab.com/gitlab-org/gitlab-ee/issues/3691personal_file
in the list of types.
restricted_project_ids
From gitlab-org/gitlab-ee#3932:
GeoNode#restricted_project_ids
should be exposed as relation GeoNode#restricted_projects
and only when it's really needed plucked to an array (see also discussion)
Edited by Toon Claes