Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/api/testing/refresh_reporting_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
class API::Testing::RefreshReportingController < API::Testing::BaseController
def create
if params[:wait].present?
ReportingAPI::RefreshJob.perform_now
ReportingAPI::RefreshJob.new.perform
render status: :ok
else
ReportingAPI::RefreshJob.perform_later
ReportingAPI::RefreshJob.perform_async
render status: :accepted
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ class API::Testing::VaccinationsSearchInNHSController < API::Testing::BaseContro

def create
if params[:wait].present?
EnqueueVaccinationsSearchInNHSJob.perform_now
EnqueueVaccinationsSearchInNHSJob.new.perform
wait_for_search_jobs_to_complete
render status: :ok
else
EnqueueVaccinationsSearchInNHSJob.perform_later
EnqueueVaccinationsSearchInNHSJob.perform_async
render status: :accepted
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/class_imports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def create
)

if @class_import.save
ProcessImportJob.perform_later(@class_import)
ProcessImportSidekiqJob.perform_async(@class_import.to_global_id.to_s)
redirect_to imports_path, flash: { success: "Import processing started" }
else
render :new, status: :unprocessable_content and return
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/cohort_imports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def create
)

if @cohort_import.save
ProcessImportJob.perform_later(@cohort_import)
ProcessImportSidekiqJob.perform_async(@cohort_import.to_global_id.to_s)
redirect_to imports_path, flash: { success: "Import processing started" }
else
render :new, status: :unprocessable_content and return
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/consent_forms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ def create_patient
end

if patient.nhs_number.nil?
PatientNHSNumberLookupJob.perform_later(patient)
PatientNHSNumberLookupSidekiqJob.perform_async(patient.id)
else
PatientUpdateFromPDSJob.perform_later(patient)
PatientUpdateFromPDSSidekiqJob.perform_async(patient.id, nil)
end

flash[:success] = "#{patient.full_name}’s record created from a consent \
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/immunisation_imports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def create
)

if @immunisation_import.save
ProcessImportJob.perform_later(@immunisation_import)
ProcessImportSidekiqJob.perform_async(
@immunisation_import.to_global_id.to_s
)
redirect_to imports_path, flash: { success: "Import processing started" }
else
render :new, status: :unprocessable_content and return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def handle_ethnicity_completion!(model)
# parent decides to answer "Yes" or "No" (they might not)
# to the ethnicity questions, the job will make sure the
# ethnicity information is copied to the matched patient.
ProcessConsentFormJob.perform_later(model.id)
ProcessConsentFormSidekiqJob.perform_async(model.id)

redirect_to submitted_parent_interface_consent_form_path(model)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def record
# answering. Running the job ensures the consent form is still
# processed and, if ethnicity was provided, it gets copied
# onto the matched patient.
ProcessConsentFormJob.perform_later(@consent_form.id)
ProcessConsentFormSidekiqJob.perform_async(@consent_form.id)

if Flipper.enabled?(:ethnicity_capture)
redirect_to parent_interface_consent_form_edit_path(
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/patients/edit_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def update_nhs_number
@patient.invalidated_at = nil

if @patient.save
PatientUpdateFromPDSJob.perform_later(@patient)
if @patient.nhs_number.present?
PatientUpdateFromPDSSidekiqJob.perform_async(@patient.id, nil)
end

redirect_to edit_patient_path(@patient)
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ def show
end

def create
SendManualSchoolConsentRemindersJob.perform_now(@session, current_user:)
SendManualSchoolConsentRemindersJob.perform_async(
@session.id,
current_user.id
)

redirect_to session_path(@session),
flash: {
Expand Down
2 changes: 1 addition & 1 deletion app/forms/bulk_remove_parents_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def save!
import
.parent_relationship_ids
.each_slice(BATCH_SIZE) do |batch_ids|
BulkRemoveParentRelationshipsJob.perform_later(
BulkRemoveParentRelationshipsSidekiqJob.perform_async(
import.to_global_id.to_s,
batch_ids,
current_user.id,
Expand Down
19 changes: 19 additions & 0 deletions app/jobs/bulk_remove_parent_relationships_sidekiq_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

class BulkRemoveParentRelationshipsSidekiqJob < ApplicationJobSidekiq
sidekiq_options queue: :imports

def perform(
import_global_id,
parent_relationship_ids_batch,
user_id,
remove_option
)
BulkRemoveParentRelationshipsJob.new.perform(
import_global_id,
parent_relationship_ids_batch,
user_id,
remove_option
)
end
end
2 changes: 1 addition & 1 deletion app/jobs/commit_patient_changesets_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def trigger_re_review(import)
import.calculating_re_review!
import.changesets.needs_re_review.each do |changeset|
changeset.calculating_review!
ReviewPatientChangesetJob.perform_later(changeset.id)
ReviewPatientChangesetSidekiqJob.perform_async(changeset.id)
end
end
end
9 changes: 9 additions & 0 deletions app/jobs/email_delivery_sidekiq_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class EmailDeliverySidekiqJob < NotifyDeliverySidekiqJob
include GovukNotifyThrottlingConcern

def perform(template_name, params)
EmailDeliveryJob.new.perform(template_name, **fetch_params(params))
end
end
4 changes: 2 additions & 2 deletions app/jobs/enqueue_automated_careplus_reports_job.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class EnqueueAutomatedCareplusReportsJob < ApplicationJobActiveJob
queue_as :careplus
class EnqueueAutomatedCareplusReportsJob < ApplicationJobSidekiq
sidekiq_options queue: :careplus

def perform
ids = Team.eligible_for_automated_careplus_reports.ids
Expand Down
4 changes: 2 additions & 2 deletions app/jobs/enqueue_location_position_updater_job.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class EnqueueLocationPositionUpdaterJob < ApplicationJobActiveJob
queue_as :third_party_data_imports
class EnqueueLocationPositionUpdaterJob < ApplicationJobSidekiq
sidekiq_options queue: :third_party_data_imports

def perform
ids = Location.where(position: nil).has_address.ids
Expand Down
4 changes: 2 additions & 2 deletions app/jobs/enqueue_patients_aged_out_of_schools_job.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class EnqueuePatientsAgedOutOfSchoolsJob < ApplicationJobActiveJob
queue_as :patients
class EnqueuePatientsAgedOutOfSchoolsJob < ApplicationJobSidekiq
sidekiq_options queue: :patients

def perform
academic_year = AcademicYear.pending
Expand Down
6 changes: 3 additions & 3 deletions app/jobs/enqueue_process_unmatched_consent_forms_job.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# frozen_string_literal: true

class EnqueueProcessUnmatchedConsentFormsJob < ApplicationJobActiveJob
class EnqueueProcessUnmatchedConsentFormsJob < ApplicationJobSidekiq
include SingleConcurrencyConcern

queue_as :consents
sidekiq_options queue: :consents

def perform
ConsentForm.unmatched.find_each do |consent_form|
ProcessConsentFormJob.perform_later(consent_form.id)
ProcessConsentFormSidekiqJob.perform_async(consent_form.id)
end
end
end
11 changes: 5 additions & 6 deletions app/jobs/enqueue_school_consent_reminders_job.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# frozen_string_literal: true

class EnqueueSchoolConsentRemindersJob < ApplicationJobActiveJob
queue_as :notifications
class EnqueueSchoolConsentRemindersJob < ApplicationJobSidekiq
sidekiq_options queue: :notifications

def perform
sessions =
session_ids =
Session
.send_consent_reminders
.joins(:location)
.merge(Location.gias_school)
.ids

sessions.find_each do |session|
SendAutomaticSchoolConsentRemindersJob.perform_later(session)
end
SendAutomaticSchoolConsentRemindersSidekiqJob.perform_bulk(session_ids.zip)
end
end
16 changes: 9 additions & 7 deletions app/jobs/enqueue_school_consent_requests_job.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# frozen_string_literal: true

class EnqueueSchoolConsentRequestsJob < ApplicationJobActiveJob
queue_as :notifications
class EnqueueSchoolConsentRequestsJob < ApplicationJobSidekiq
sidekiq_options queue: :notifications

def perform
sessions =
Session.send_consent_requests.joins(:location).merge(Location.gias_school)
session_ids =
Session
.send_consent_requests
.joins(:location)
.merge(Location.gias_school)
.ids

sessions.find_each do |session|
SendSchoolConsentRequestsJob.perform_later(session)
end
SendSchoolConsentRequestsSidekiqJob.perform_bulk(session_ids.zip)
end
end
11 changes: 5 additions & 6 deletions app/jobs/enqueue_school_session_reminders_job.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# frozen_string_literal: true

class EnqueueSchoolSessionRemindersJob < ApplicationJobActiveJob
queue_as :notifications
class EnqueueSchoolSessionRemindersJob < ApplicationJobSidekiq
sidekiq_options queue: :notifications

def perform
sessions =
session_ids =
Session
.includes(:session_programme_year_groups)
.has_date(Date.tomorrow)
.joins(:location)
.merge(Location.gias_school)
.ids

sessions.find_each do |session|
SendSchoolSessionRemindersJob.perform_later(session)
end
SendSchoolSessionRemindersSidekiqJob.perform_bulk(session_ids.zip)
end
end
4 changes: 2 additions & 2 deletions app/jobs/enqueue_update_patients_from_pds_job.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

class EnqueueUpdatePatientsFromPDSJob < ApplicationJobActiveJob
class EnqueueUpdatePatientsFromPDSJob < ApplicationJobSidekiq
include SingleConcurrencyConcern

queue_as :pds
sidekiq_options queue: :pds

def perform
scope = Patient.not_deceased
Expand Down
6 changes: 3 additions & 3 deletions app/jobs/enqueue_vaccinations_search_in_nhs_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
# sessions, starting from 2 days before invitations or consent requests are sent
# out and ending once the last date of the sessions has passed. For all other
# patients we want to ensure a search is performed every 28 days at most.
class EnqueueVaccinationsSearchInNHSJob < ApplicationJobActiveJob
queue_as :immunisations_api_search
class EnqueueVaccinationsSearchInNHSJob < ApplicationJobSidekiq
sidekiq_options queue: :immunisations_api_search

def perform(programme_types: nil)
def perform(programme_types = nil)
programme_types ||= Programme.all.map(&:type)
patient_ids = []

Expand Down
8 changes: 4 additions & 4 deletions app/jobs/gias_import_job.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# frozen_string_literal: true

class GIASImportJob < ApplicationJobActiveJob
class GIASImportJob < ApplicationJobSidekiq
include SingleConcurrencyConcern

queue_as :third_party_data_imports
sidekiq_options queue: :third_party_data_imports

def perform(dry_run: false)
def perform
GIAS.download

results = GIAS.check_import
GIAS.log_import_check_results(results)

GIAS.import unless dry_run
GIAS.import
end
end
2 changes: 1 addition & 1 deletion app/jobs/important_notice_generator_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ImportantNoticeGeneratorJob < ApplicationJobActiveJob
restricted: :restricted_at
}.freeze

def perform(patient_ids = nil)
def perform(patient_ids)
scope = Patient.includes(:teams, vaccination_records: %i[team])

if patient_ids.present?
Expand Down
9 changes: 9 additions & 0 deletions app/jobs/important_notice_generator_sidekiq_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class ImportantNoticeGeneratorSidekiqJob < ApplicationJobSidekiq
sidekiq_options queue: :cache

def perform(patient_ids)
ImportantNoticeGeneratorJob.new.perform(patient_ids)
end
end
4 changes: 2 additions & 2 deletions app/jobs/invalidate_self_consents_job.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class InvalidateSelfConsentsJob < ApplicationJobActiveJob
queue_as :consents
class InvalidateSelfConsentsJob < ApplicationJobSidekiq
sidekiq_options queue: :consents

def perform
programmes = Programme.all
Expand Down
48 changes: 48 additions & 0 deletions app/jobs/notify_delivery_sidekiq_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# frozen_string_literal: true

require "notifications/client"

# This is a temporary copy of `NotifyDeliveryJob` that will be removed when
# all jobs have been converted to Sidekiq.
class NotifyDeliverySidekiqJob < ApplicationJobSidekiq
TEAM_ONLY_API_KEY_MESSAGE =
"Can’t send to this recipient using a team-only API key"

sidekiq_options queue: :notifications

def fetch_params(params)
{
academic_year: params["academic_year"],
consent: (id = params["consent_id"]) && Consent.find(id),
consent_form: (id = params["consent_form_id"]) && ConsentForm.find(id),
disease_types: params["disease_types"],
parent: (id = params["parent_id"]) && Parent.find(id),
patient: (id = params["patient_id"]) && Patient.find(id),
programme_types: params["programme_types"] || [],
sent_by: (id = params["sent_by_user_id"]) && User.find(id),
session: (id = params["session_id"]) && Session.find(id),
team: (id = params["team_id"]) && Team.find(id),
team_location: (id = params["team_location_id"]) && TeamLocation.find(id),
vaccination_record:
(id = params["vaccination_record_id"]) && VaccinationRecord.find(id)
}
end

def self.client
@client ||=
Notifications::Client.new(
Settings.govuk_notify["#{Settings.govuk_notify.mode}_key"]
)
end

def self.deliveries
@deliveries ||= []
end

def self.send_via_notify? = Settings.govuk_notify&.enabled

def self.send_via_test? = Rails.env.test?

class UnknownTemplate < StandardError
end
end
Loading
Loading