Commit 763fb416 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Refactor finders to define unscoped base model

parent 8e7c1f16
......@@ -2,6 +2,8 @@
module Geo
class AttachmentRegistryFinder < FileRegistryFinder
# Counts all existing registries independent
# of any change on filters / selective sync
def count_registry
Geo::FileRegistry.attachments.count
end
......@@ -54,7 +56,7 @@ module Geo
# rubocop: disable CodeReuse/ActiveRecord
def find_migrated_local(batch_size:, except_file_ids: [])
attachments
all_attachments
.inner_join_file_registry
.with_files_stored_remotely
.merge(Geo::FileRegistry.attachments)
......@@ -89,7 +91,11 @@ module Geo
private
def attachments
local_storage_only? ? current_node.attachments.with_files_stored_locally : current_node.attachments
local_storage_only? ? all_attachments.with_files_stored_locally : all_attachments
end
def all_attachments
current_node.attachments
end
def registries_for_attachments
......
......@@ -2,6 +2,8 @@
module Geo
class JobArtifactRegistryFinder < FileRegistryFinder
# Counts all existing registries independent
# of any change on filters / selective sync
def count_registry
Geo::JobArtifactRegistry.count
end
......@@ -52,7 +54,7 @@ module Geo
# rubocop: disable CodeReuse/ActiveRecord
def find_migrated_local(batch_size:, except_artifact_ids: [])
current_node.job_artifacts
all_job_artifacts
.inner_join_job_artifact_registry
.with_files_stored_remotely
.id_not_in(except_artifact_ids)
......@@ -84,7 +86,11 @@ module Geo
private
def job_artifacts
local_storage_only? ? current_node.job_artifacts.with_files_stored_locally : current_node.job_artifacts
local_storage_only? ? all_job_artifacts.with_files_stored_locally : all_job_artifacts
end
def all_job_artifacts
current_node.job_artifacts
end
def registries_for_job_artifacts
......
......@@ -2,6 +2,8 @@
module Geo
class LfsObjectRegistryFinder < FileRegistryFinder
# Counts all existing registries independent
# of any change on filters / selective sync
def count_registry
Geo::FileRegistry.lfs_objects.count
end
......
......@@ -219,7 +219,7 @@ describe Geo::JobArtifactRegistryFinder, :geo_fdw do
context 'with object storage sync disabled' do
let(:secondary) { create(:geo_node, :local_storage) }
it 'does not apply the selective sync restriction' do
it 'counts file registries for job artifacts ignoring remote artifacts' do
expect(subject.count_registry).to eq 4
end
end
......@@ -265,7 +265,7 @@ describe Geo::JobArtifactRegistryFinder, :geo_fdw do
context 'with object storage sync disabled' do
let(:secondary) { create(:geo_node, :local_storage) }
it 'returns job artifacts without an entry on the tracking database, ignoring expired ones' do
it 'returns job artifacts without an entry on the tracking database, ignoring expired ones and remotes' do
job_artifacts = subject.find_unsynced(batch_size: 10)
expect(job_artifacts).to match_ids(job_artifact_2, job_artifact_4)
......
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