Commit bd05c473 authored by Michael Kozono's avatar Michael Kozono

Use symbols where possible, except for job args

parent 33279acb
......@@ -76,7 +76,7 @@ module Geo
end
def upload?
Geo::FileService::DEFAULT_OBJECT_TYPES.include?(object_type)
Geo::FileService::DEFAULT_OBJECT_TYPES.include?(object_type.to_s)
end
def lease_key
......
......@@ -9,7 +9,7 @@ module Geo
DEFAULT_SERVICE_TYPE = 'file'.freeze
def initialize(object_type, object_db_id)
@object_type = object_type.to_s
@object_type = object_type.to_sym
@object_db_id = object_db_id
end
......@@ -21,19 +21,19 @@ module Geo
def service_klass_name
klass_name =
if DEFAULT_OBJECT_TYPES.include?(object_type)
if DEFAULT_OBJECT_TYPES.include?(object_type.to_s)
DEFAULT_SERVICE_TYPE
else
object_type
end
klass_name.camelize
klass_name.to_s.camelize
end
def base_log_data(message)
{
class: self.class.name,
object_type: object_type,
object_type: object_type.to_s,
object_db_id: object_db_id,
message: message
}
......
......@@ -60,7 +60,7 @@ module Geo
def find_unsynced_lfs_objects_ids(batch_size:)
lfs_objects_finder.find_unsynced_lfs_objects(
batch_size: batch_size,
except_file_ids: scheduled_file_ids('lfs'))
except_file_ids: scheduled_file_ids(:lfs))
.pluck(:id)
.map { |id| ['lfs', id] }
end
......@@ -76,7 +76,7 @@ module Geo
def find_unsynced_job_artifacts_ids(batch_size:)
job_artifacts_finder.find_unsynced_job_artifacts(
batch_size: batch_size,
except_artifact_ids: scheduled_file_ids('job_artifact'))
except_artifact_ids: scheduled_file_ids(:job_artifact))
.pluck(:id)
.map { |id| ['job_artifact', id] }
end
......@@ -92,7 +92,7 @@ module Geo
def find_failed_lfs_objects_ids(batch_size:)
lfs_objects_finder.find_failed_lfs_objects_registries
.retry_due
.where.not(file_id: scheduled_file_ids('lfs'))
.where.not(file_id: scheduled_file_ids(:lfs))
.limit(batch_size)
.pluck(:file_id).map { |id| ['lfs', id] }
end
......@@ -100,7 +100,7 @@ module Geo
def find_failed_artifacts_ids(batch_size:)
job_artifacts_finder.find_failed_job_artifacts_registries
.retry_due
.where.not(artifact_id: scheduled_file_ids('job_artifact'))
.where.not(artifact_id: scheduled_file_ids(:job_artifact))
.limit(batch_size)
.pluck(:artifact_id).map { |id| ['job_artifact', id] }
end
......@@ -116,7 +116,7 @@ module Geo
def find_synced_missing_on_primary_lfs_objects_ids(batch_size:)
lfs_objects_finder.find_synced_missing_on_primary_lfs_objects_registries
.retry_due
.where.not(file_id: scheduled_file_ids('lfs'))
.where.not(file_id: scheduled_file_ids(:lfs))
.limit(batch_size)
.pluck(:file_id).map { |id| ['lfs', id] }
end
......@@ -124,15 +124,16 @@ module Geo
def find_synced_missing_on_primary_job_artifacts_ids(batch_size:)
job_artifacts_finder.find_synced_missing_on_primary_job_artifacts_registries
.retry_due
.where.not(artifact_id: scheduled_file_ids('job_artifact'))
.where.not(artifact_id: scheduled_file_ids(:job_artifact))
.limit(batch_size)
.pluck(:artifact_id).map { |id| ['job_artifact', id] }
end
def scheduled_file_ids(file_types)
file_types = Array(file_types)
file_types = file_types.map(&:to_s)
scheduled_jobs.select { |data| file_types.include?(data[:type]) }.map { |data| data[:id] }
scheduled_jobs.select { |data| file_types.include?(data[:type].to_s) }.map { |data| data[:id] }
end
end
end
......@@ -6,7 +6,7 @@ module Geo
sidekiq_options retry: 3, dead: false
def perform(object_type, object_id)
Geo::FileDownloadService.new(object_type, object_id).execute
Geo::FileDownloadService.new(object_type.to_sym, object_id).execute
end
end
end
......@@ -20,7 +20,7 @@ module Geo
end
def schedule_job(object_type, object_db_id)
job_id = ::Geo::FileRegistryRemovalWorker.perform_async(object_type, object_db_id)
job_id = ::Geo::FileRegistryRemovalWorker.perform_async(object_type.to_s, object_db_id)
if job_id
retval = { id: object_db_id, type: object_type, job_id: job_id }
......@@ -47,7 +47,7 @@ module Geo
lfs_objects_finder.find_migrated_local_lfs_objects(batch_size: batch_size, except_file_ids: scheduled_file_ids(:lfs))
.pluck(:id)
.map { |id| [:lfs, id] }
.map { |id| ['lfs', id] }
end
def find_migrated_local_attachments_ids(batch_size:)
......@@ -63,13 +63,14 @@ module Geo
job_artifacts_finder.find_migrated_local_job_artifacts(batch_size: batch_size, except_artifact_ids: scheduled_file_ids(:job_artifact))
.pluck(:id)
.map { |id| [:job_artifact, id] }
.map { |id| ['job_artifact', id] }
end
def scheduled_file_ids(file_types)
file_types = Array(file_types)
file_types = file_types.map(&:to_s)
scheduled_jobs.select { |data| file_types.include?(data[:type]) }.map { |data| data[:id] }
scheduled_jobs.select { |data| file_types.include?(data[:type].to_s) }.map { |data| data[:id] }
end
def attachments_object_store_enabled?
......
......@@ -5,7 +5,7 @@ describe Geo::FileDownloadWorker, :geo do
it 'instantiates and executes FileDownloadService' do
service = double(:service)
expect(service).to receive(:execute)
expect(Geo::FileDownloadService).to receive(:new).with('job_artifact', 1).and_return(service)
expect(Geo::FileDownloadService).to receive(:new).with(:job_artifact, 1).and_return(service)
described_class.new.perform('job_artifact', 1)
end
end
......
......@@ -39,14 +39,14 @@ describe Geo::MigratedLocalFilesCleanUpWorker, :geo do
end
it 'schedules job for file stored remotely and synced locally' do
expect(worker).to receive(:schedule_job).with(:lfs, lfs_object_remote.id)
expect(worker).to receive(:schedule_job).with('lfs', lfs_object_remote.id)
expect(worker).not_to receive(:schedule_job).with(anything, lfs_object_local.id)
worker.perform
end
it 'schedules worker for file stored remotely and synced locally' do
expect(Geo::FileRegistryRemovalWorker).to receive(:perform_async).with(:lfs, lfs_object_remote.id)
expect(Geo::FileRegistryRemovalWorker).to receive(:perform_async).with('lfs', lfs_object_remote.id)
expect(Geo::FileRegistryRemovalWorker).not_to receive(:perform_async).with(anything, lfs_object_local.id)
worker.perform
......@@ -127,14 +127,14 @@ describe Geo::MigratedLocalFilesCleanUpWorker, :geo do
end
it 'schedules job for artifact stored remotely and synced locally' do
expect(worker).to receive(:schedule_job).with(:job_artifact, job_artifact_remote.id)
expect(worker).to receive(:schedule_job).with('job_artifact', job_artifact_remote.id)
expect(worker).not_to receive(:schedule_job).with(anything, job_artifact_local.id)
worker.perform
end
it 'schedules worker for artifact stored remotely and synced locally' do
expect(Geo::FileRegistryRemovalWorker).to receive(:perform_async).with(:job_artifact, job_artifact_remote.id)
expect(Geo::FileRegistryRemovalWorker).to receive(:perform_async).with('job_artifact', job_artifact_remote.id)
expect(Geo::FileRegistryRemovalWorker).not_to receive(:perform_async).with(anything, job_artifact_local.id)
worker.perform
......
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