Skip to content

Commit

Permalink
[RUBY-2477] Cache copy cards order in memory before transient registr…
Browse files Browse the repository at this point in the history
…ation is deleted
  • Loading branch information
jjromeo committed Sep 27, 2023
1 parent 52db1b5 commit a76dbb9
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def run(transient_registration)
private

def complete_order_copy_cards
# Called to get copy cards order before transient registration is deleted later
cached_copy_cards_order

update_registration

delete_transient_registration
Expand Down Expand Up @@ -44,16 +47,16 @@ def delete_transient_registration
def send_confirmation_email
if @transient_registration.unpaid_balance?
Notify::CopyCardsAwaitingPaymentEmailService
.run(registration: registration, order: copy_cards_order)
.run(registration: registration, order: cached_copy_cards_order)
else
Notify::CopyCardsOrderCompletedEmailService
.run(registration: registration, order: copy_cards_order)
.run(registration: registration, order: cached_copy_cards_order)
end
rescue StandardError => e
Airbrake.notify(e, registration_no: registration.reg_identifier) if defined?(Airbrake)
end

def copy_cards_order
def cached_copy_cards_order
@_copy_cards_order ||= transient_registration.reload.finance_details.orders.last
end
end
Expand Down

0 comments on commit a76dbb9

Please sign in to comment.