Skip to content

Commit

Permalink
Move import jobs to the Import namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Freika committed Oct 3, 2024
1 parent dde76fd commit 6566455
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/jobs/enqueue_background_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class EnqueueBackgroundJob < ApplicationJob
def perform(job_name, user_id)
case job_name
when 'start_immich_import'
ImportImmichGeodataJob.perform_later(user_id)
Import::ImmichGeodataJob.perform_later(user_id)
when 'start_reverse_geocoding', 'continue_reverse_geocoding'
Jobs::Create.new(job_name, user_id).call
else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class ImportGoogleTakeoutJob < ApplicationJob
class Import::GoogleTakeoutJob < ApplicationJob
queue_as :imports
sidekiq_options retry: false

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class ImportImmichGeodataJob < ApplicationJob
class Import::ImmichGeodataJob < ApplicationJob
queue_as :imports

def perform(user_id)
Expand Down
2 changes: 1 addition & 1 deletion app/services/tasks/imports/google_records.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def read_file

def schedule_import_jobs(json_data, import_id)
json_data['locations'].each do |json|
ImportGoogleTakeoutJob.perform_later(import_id, json.to_json)
Import::GoogleTakeoutJob.perform_later(import_id, json.to_json)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

require 'rails_helper'

RSpec.describe ImportImmichGeodataJob, type: :job do
RSpec.describe Import::ImmichGeodataJob, type: :job do
describe '#perform' do
let(:user) { create(:user) }

it 'calls Immich::ImportGeodata' do
expect_any_instance_of(Immich::ImportGeodata).to receive(:call)

ImportImmichGeodataJob.perform_now(user.id)
Import::ImmichGeodataJob.perform_now(user.id)
end
end
end
4 changes: 2 additions & 2 deletions spec/services/tasks/imports/google_records_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
let(:user) { create(:user) }
let(:file_path) { Rails.root.join('spec/fixtures/files/google/records.json') }

it 'schedules the ImportGoogleTakeoutJob' do
expect(ImportGoogleTakeoutJob).to receive(:perform_later).exactly(3).times
it 'schedules the Import::GoogleTakeoutJob' do
expect(Import::GoogleTakeoutJob).to receive(:perform_later).exactly(3).times

described_class.new(file_path, user.email).call
end
Expand Down

0 comments on commit 6566455

Please sign in to comment.