fix: orders from before the PNG print file are generated again, once
All checks were successful
Build and deploy / Validate source (push) Successful in 7s
Build and deploy / Integration suite on a real stack (push) Successful in 6m1s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m0s

An order generated before item 13 had a PDF print file and no strips,
so the 100% viewer opened it blank. Those still in Arte recebida, with
no approved final and no customer correction, are generated again once
as PNG with strips (migration png-regenerate-v1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-09 13:25:52 -03:00
parent a69b9f71c2
commit 049f51b56a

View File

@@ -581,3 +581,20 @@ CREATE TABLE IF NOT EXISTS dtf_local.machine_snoozes (
snoozed_by text NOT NULL, snoozed_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY(machine_id, alert, cycle_from)
);
-- Orders generated before the print file was a PNG with its strips (item 13)
-- open blank in the 100% viewer. Those not approved yet are generated again,
-- once: the same layout, now as PNG with strips. An approved final, a
-- customer's correction or a cancelled order is left as it is.
DO $$ BEGIN
IF NOT EXISTS (SELECT 1 FROM dtf_local.migrations WHERE name='png-regenerate-v1') THEN
UPDATE dtf_local.print_files p SET status='pending', attempts=0, claimed_at=NULL, claim_token=NULL,
finished_at=NULL, upload_id=NULL, detail='{}'
FROM dtf_local.orders o
WHERE o.id=p.order_id AND o.state='rec' AND o.cancelled_at IS NULL
AND p.status='ready' AND NOT (p.detail ? 'format')
AND NOT EXISTS (SELECT 1 FROM dtf_local.order_files f WHERE f.order_id=p.order_id
AND f.item_index=p.item_index AND f.active);
INSERT INTO dtf_local.migrations VALUES('png-regenerate-v1');
END IF;
END $$;