Skip to content

Commit fd3bd16

Browse files
committed
Convert remaining jobs to Sidekiq
This converts the remaining ActiveJob jobs to be Sidekiq-only. These jobs all accept arguments, meaning we need to be careful about the serialisation and deserialisation of the arguments. To ensure the migration doesn't result in any missed jobs, this commit adds Sidekiq-only versions of all the jobs which are queued instead of the ActiveJob ones. Any ActiveJob jobs left in the queue will continue to execute. Jira-Issue: MAV-7288
1 parent 97627b6 commit fd3bd16

82 files changed

Lines changed: 711 additions & 515 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/controllers/class_imports_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def create
2929
)
3030

3131
if @class_import.save
32-
ProcessImportJob.perform_later(@class_import)
32+
ProcessImportSidekiqJob.perform_async(@class_import.to_global_id.to_s)
3333
redirect_to imports_path, flash: { success: "Import processing started" }
3434
else
3535
render :new, status: :unprocessable_content and return

app/controllers/cohort_imports_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def create
2727
)
2828

2929
if @cohort_import.save
30-
ProcessImportJob.perform_later(@cohort_import)
30+
ProcessImportSidekiqJob.perform_async(@cohort_import.to_global_id.to_s)
3131
redirect_to imports_path, flash: { success: "Import processing started" }
3232
else
3333
render :new, status: :unprocessable_content and return

app/controllers/consent_forms_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ def create_patient
118118
end
119119

120120
if patient.nhs_number.nil?
121-
PatientNHSNumberLookupJob.perform_later(patient)
121+
PatientNHSNumberLookupSidekiqJob.perform_async(patient.id)
122122
else
123-
PatientUpdateFromPDSJob.perform_later(patient)
123+
PatientUpdateFromPDSSidekiqJob.perform_async(patient.id, nil)
124124
end
125125

126126
flash[:success] = "#{patient.full_name}’s record created from a consent \

app/controllers/immunisation_imports_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def create
2323
)
2424

2525
if @immunisation_import.save
26-
ProcessImportJob.perform_later(@immunisation_import)
26+
ProcessImportSidekiqJob.perform_async(
27+
@immunisation_import.to_global_id.to_s
28+
)
2729
redirect_to imports_path, flash: { success: "Import processing started" }
2830
else
2931
render :new, status: :unprocessable_content and return

app/controllers/parent_interface/consent_forms/edit_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def handle_ethnicity_completion!(model)
9696
# parent decides to answer "Yes" or "No" (they might not)
9797
# to the ethnicity questions, the job will make sure the
9898
# ethnicity information is copied to the matched patient.
99-
ProcessConsentFormJob.perform_later(model.id)
99+
ProcessConsentFormSidekiqJob.perform_async(model.id)
100100

101101
redirect_to submitted_parent_interface_consent_form_path(model)
102102
end

app/controllers/parent_interface/consent_forms_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def record
6767
# answering. Running the job ensures the consent form is still
6868
# processed and, if ethnicity was provided, it gets copied
6969
# onto the matched patient.
70-
ProcessConsentFormJob.perform_later(@consent_form.id)
70+
ProcessConsentFormSidekiqJob.perform_async(@consent_form.id)
7171

7272
if Flipper.enabled?(:ethnicity_capture)
7373
redirect_to parent_interface_consent_form_edit_path(

app/controllers/patients/edit_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def update_nhs_number
2222
@patient.invalidated_at = nil
2323

2424
if @patient.save
25-
PatientUpdateFromPDSJob.perform_later(@patient)
25+
if @patient.nhs_number.present?
26+
PatientUpdateFromPDSSidekiqJob.perform_async(@patient.id, nil)
27+
end
2628

2729
redirect_to edit_patient_path(@patient)
2830
else

app/controllers/sessions/manage_consent_reminders_controller.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ def show
77
end
88

99
def create
10-
SendManualSchoolConsentRemindersJob.perform_now(@session, current_user:)
10+
SendManualSchoolConsentRemindersJob.perform_async(
11+
@session.id,
12+
current_user.id
13+
)
1114

1215
redirect_to session_path(@session),
1316
flash: {

app/forms/bulk_remove_parents_form.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def save!
3131
import
3232
.parent_relationship_ids
3333
.each_slice(BATCH_SIZE) do |batch_ids|
34-
BulkRemoveParentRelationshipsJob.perform_later(
34+
BulkRemoveParentRelationshipsSidekiqJob.perform_async(
3535
import.to_global_id.to_s,
3636
batch_ids,
3737
current_user.id,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# frozen_string_literal: true
2+
3+
class BulkRemoveParentRelationshipsSidekiqJob < ApplicationJobSidekiq
4+
sidekiq_options queue: :imports
5+
6+
def perform(
7+
import_global_id,
8+
parent_relationship_ids_batch,
9+
user_id,
10+
remove_option
11+
)
12+
BulkRemoveParentRelationshipsJob.new.perform(
13+
import_global_id,
14+
parent_relationship_ids_batch,
15+
user_id,
16+
remove_option
17+
)
18+
end
19+
end

0 commit comments

Comments
 (0)