-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14335 from transcom/B-21393V2
B 21393 - Consolidated PPM Allowable Weights
- Loading branch information
Showing
59 changed files
with
768 additions
and
445 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
migrations/app/schema/20241008133341_consolidate_allowable_weight_in_ppm_shipments.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
SET statement_timeout = 300000; | ||
SET lock_timeout = 300000; | ||
SET idle_in_transaction_session_timeout = 300000; | ||
|
||
ALTER TABLE ppm_shipments | ||
ADD COLUMN IF NOT EXISTS allowable_weight integer; | ||
|
||
COMMENT on COLUMN ppm_shipments.allowable_weight IS 'Combined allowable weight for all trips.'; | ||
|
||
UPDATE ppm_shipments | ||
SET allowable_weight = summed_weights.summed_allowable_weight | ||
FROM ( | ||
SELECT ppm_shipment_id, SUM(coalesce(full_weight, 0) - coalesce(empty_weight, 0)) AS summed_allowable_weight FROM public.weight_tickets | ||
GROUP BY ppm_shipment_id | ||
) AS summed_weights | ||
WHERE ppm_shipments.id = summed_weights.ppm_shipment_id | ||
AND ppm_shipments.status = 'NEEDS_CLOSEOUT'; | ||
|
||
UPDATE ppm_shipments | ||
SET allowable_weight = summed_weights.summed_allowable_weight | ||
FROM ( | ||
SELECT ppm_shipment_id, SUM(weight_tickets.allowable_weight) AS summed_allowable_weight FROM public.weight_tickets | ||
GROUP BY ppm_shipment_id | ||
) AS summed_weights | ||
WHERE ppm_shipments.id = summed_weights.ppm_shipment_id | ||
AND ppm_shipments.status = 'CLOSEOUT_COMPLETE'; | ||
|
||
ALTER TABLE weight_tickets | ||
DROP COLUMN IF EXISTS allowable_weight; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.