Commit 7d1f8ba4 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Improved with codestyle changes

parent 94b5f213
......@@ -28,11 +28,10 @@ module Geo
end
def syncable
if selective_sync?
attachments
else
local_storage_only? ? Upload.with_files_stored_locally : Upload
end
return attachments if selective_sync?
return Upload.with_files_stored_locally if local_storage_only?
Upload
end
# Find limited amount of non replicated attachments.
......
......@@ -79,7 +79,7 @@ module Geo
end
def local_storage_only?
!current_node.sync_object_storage
!current_node&.sync_object_storage
end
end
end
......@@ -25,11 +25,10 @@ module Geo
end
def syncable
if selective_sync?
job_artifacts.not_expired
else
local_storage_only? ? Ci::JobArtifact.not_expired.with_files_stored_locally : Ci::JobArtifact.not_expired
end
return job_artifacts.not_expired if selective_sync?
return Ci::JobArtifact.not_expired.with_files_stored_locally if local_storage_only?
Ci::JobArtifact.not_expired
end
# Find limited amount of non replicated job artifacts.
......
......@@ -25,11 +25,10 @@ module Geo
end
def syncable
if selective_sync?
lfs_objects
else
local_storage_only? ? LfsObject.with_files_stored_locally : LfsObject
end
return lfs_objects if selective_sync?
return LfsObject.with_files_stored_locally if local_storage_only?
LfsObject
end
# Find limited amount of non replicated lfs objects.
......
......@@ -128,7 +128,11 @@ module Geo::SelectiveSync
end
def attachments_for_model_type_with_id_in(model_type, model_ids)
uploads_table[:model_type].eq(model_type).and(uploads_table[:model_id].in(model_ids.arel))
uploads_table[:model_type]
.eq(model_type)
.and(
uploads_table[:model_id].in(model_ids.arel)
)
end
# This concern doesn't define a geo_node_namespace_links relation. That's
......
......@@ -28,7 +28,7 @@ module Geo
.on(arel_table[:id].eq(file_registry_table[:file_id]))
joins(join_statement.join_sources)
.merge(Geo::FileRegistry.lfs_objects)
.merge(Geo::FileRegistry.lfs_objects)
end
def missing_file_registry
......
......@@ -41,19 +41,21 @@ describe Geo::AttachmentRegistryFinder, :geo, :geo_fdw do
create(:geo_file_registry, :avatar, file_id: upload_remote_synced_project.id)
end
it 'returns attachments without an entry on the tracking database' do
attachments = subject.find_unsynced(batch_size: 10)
context 'with object storage sync enabled' do
it 'returns attachments without an entry on the tracking database' do
attachments = subject.find_unsynced(batch_size: 10)
expect(attachments).to match_ids(upload_issuable_synced_nested_project, upload_unsynced_project,
upload_synced_project, upload_personal_snippet, upload_remote_unsynced_project,
upload_remote_synced_group)
end
expect(attachments).to match_ids(upload_issuable_synced_nested_project, upload_unsynced_project,
upload_synced_project, upload_personal_snippet, upload_remote_unsynced_project,
upload_remote_synced_group)
end
it 'returns attachments without an entry on the tracking database, excluding from exception list' do
attachments = subject.find_unsynced(batch_size: 10, except_file_ids: [upload_issuable_synced_nested_project.id])
it 'returns attachments without an entry on the tracking database, excluding from exception list' do
attachments = subject.find_unsynced(batch_size: 10, except_file_ids: [upload_issuable_synced_nested_project.id])
expect(attachments).to match_ids(upload_unsynced_project, upload_synced_project, upload_personal_snippet,
upload_remote_unsynced_project, upload_remote_synced_group)
expect(attachments).to match_ids(upload_unsynced_project, upload_synced_project, upload_personal_snippet,
upload_remote_unsynced_project, upload_remote_synced_group)
end
end
context 'with object storage sync disabled' do
......@@ -143,8 +145,10 @@ describe Geo::AttachmentRegistryFinder, :geo, :geo_fdw do
create(:geo_file_registry, :attachment, file_id: upload_remote_unsynced_project.id)
end
it 'counts attachments that have been synced' do
expect(subject.count_synced).to eq 7
context 'with object storage sync enabled' do
it 'counts attachments that have been synced' do
expect(subject.count_synced).to eq 7
end
end
context 'with object storage sync disabled' do
......@@ -184,8 +188,10 @@ describe Geo::AttachmentRegistryFinder, :geo, :geo_fdw do
create(:geo_file_registry, :attachment, :failed, file_id: upload_remote_unsynced_project.id)
end
it 'counts attachments that sync has failed' do
expect(subject.count_failed).to eq 7
context 'with object storage sync enabled' do
it 'counts attachments that sync has failed' do
expect(subject.count_failed).to eq 7
end
end
context 'with object storage sync disabled' do
......@@ -225,8 +231,10 @@ describe Geo::AttachmentRegistryFinder, :geo, :geo_fdw do
create(:geo_file_registry, :attachment, file_id: upload_remote_unsynced_project.id, missing_on_primary: true)
end
it 'counts attachments that have been synced and are missing on the primary' do
expect(subject.count_synced_missing_on_primary).to eq 6
context 'with object storage sync enabled' do
it 'counts attachments that have been synced and are missing on the primary' do
expect(subject.count_synced_missing_on_primary).to eq 6
end
end
context 'with object storage sync disabled' do
......@@ -255,8 +263,10 @@ describe Geo::AttachmentRegistryFinder, :geo, :geo_fdw do
end
describe '#count_syncable' do
it 'counts attachments' do
expect(subject.count_syncable).to eq 9
context 'with object storage sync enabled' do
it 'counts attachments' do
expect(subject.count_syncable).to eq 9
end
end
context 'with object storage sync disabled' do
......@@ -297,8 +307,10 @@ describe Geo::AttachmentRegistryFinder, :geo, :geo_fdw do
create(:geo_file_registry, :attachment, file_id: upload_remote_synced_group.id, missing_on_primary: true)
end
it 'counts file registries for attachments' do
expect(subject.count_registry).to eq 9
context 'with object storage sync enabled' do
it 'counts file registries for attachments' do
expect(subject.count_registry).to eq 9
end
end
context 'with object storage sync disabled' do
......
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