fix: a film's parts go to the machine in their own order, p2 before p10
Some checks failed
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Failing after 47s
Build and deploy / Secret scan and release gate (push) Successful in 9s
Build and deploy / Publish images (push) Has been skipped

The hot folder and the folders' list ordered the parts by name, so a film of
ten parts or more (#81, 91,5 m) would send p10 second. They now follow the
part number. Checked on Postgres 17 with an 11-part film.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-27 14:16:31 -03:00
parent 331e43aa14
commit b2876487bd
2 changed files with 10 additions and 4 deletions

View File

@@ -54,11 +54,15 @@ def start(c, order_id):
"""The order entered Imprimindo: its approved finals queue for its
machine's folder, item by item, part by part; on a reprint only the items
chosen to go again (orders.print_items)."""
# A film's parts in their own order, p2 before p10: by name, a 91 m film
# would print p10 second.
files = c.execute('''SELECT f.item_index, f.upload_id, u.name FROM dtf_local.order_files f
JOIN dtf_local.uploads u ON u.id=f.upload_id JOIN dtf_local.orders o ON o.id=f.order_id
LEFT JOIN dtf_local.print_parts pp ON pp.order_id=f.order_id AND pp.item_index=f.item_index
AND pp.upload_id=f.upload_id
WHERE f.order_id=%s AND f.kind='final' AND f.active
AND (o.print_items IS NULL OR f.item_index = ANY(o.print_items))
ORDER BY f.item_index, u.name''', (order_id,)).fetchall()
ORDER BY f.item_index, pp.part NULLS LAST, length(u.name), u.name''', (order_id,)).fetchall()
round_ = c.execute('SELECT COALESCE(max(round), 0) + 1 AS r FROM dtf_local.hot_parts WHERE order_id=%s',
(order_id,)).fetchone()['r']
for seq, row in enumerate(files, 1):