Skip to content

Commit

Permalink
fix(stock): add WHERE to max values
Browse files Browse the repository at this point in the history
Adds a missing WHERE to the max values to appropriately compute the
max_values table calculation.  Seems to also speed up the computation
greatly.
  • Loading branch information
jniles committed Feb 20, 2021
1 parent b1b5e8f commit 4730ef7
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions server/models/procedures/stock.sql
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ CREATE PROCEDURE ComputeStockStatusForStagedInventory(
SELECT sms.inventory_uuid, tmd.max_date, sms.sum_quantity, sms.sum_in_quantity, sms.sum_out_quantity_exit, sum_out_quantity_consumption
FROM stock_movement_status AS sms JOIN tmp_max_dates AS tmd ON
sms.inventory_uuid = tmd.inventory_uuid AND tmd.max_date = sms.date
WHERE sms.depot_uuid = _depot_uuid
GROUP BY sms.inventory_uuid, sms.date;

-- we don't need to know those max dates anymore
Expand Down

0 comments on commit 4730ef7

Please sign in to comment.