From 925676f136af9c17a19595bad9bb35ce8ced1267 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 30 Apr 2021 12:48:53 +0100 Subject: [PATCH] Split Order::Updater#update into two methods There are two distinct (and very important) operations happening here. The first is to update all adjustments (which can be *incredibly* expensive) and the second is to ensure the order's totals and shipping/payment states are correct. There are lots of places where we currently do both of these things where in fact we only need to do the latter (and skip the really expensive part). --- .../app/services/order_management/order/updater.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engines/order_management/app/services/order_management/order/updater.rb b/engines/order_management/app/services/order_management/order/updater.rb index c432214751..0aa3a932ef 100644 --- a/engines/order_management/app/services/order_management/order/updater.rb +++ b/engines/order_management/app/services/order_management/order/updater.rb @@ -20,6 +20,10 @@ module OrderManagement # associations try to save and then in turn try to call +update!+ again.) def update update_all_adjustments + update_totals_and_states + end + + def update_totals_and_states update_totals if order.completed?