fix: a film's parts go to the machine in their own order, p2 before p10
Some checks failed
Some checks failed
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:
@@ -50,14 +50,16 @@ def print_ready(c, states, only=None, paid_after=None):
|
||||
these orders, `paid_after` to the orders paid since then."""
|
||||
ids = None if only is None else list(only)
|
||||
rows = c.execute(f'''SELECT o.id AS order_id,o.state,o.number,f.item_index,f.upload_id,u.object_key,u.name,
|
||||
COALESCE(o.queue_key, extract(epoch FROM o.created_at)) AS position
|
||||
COALESCE(o.queue_key, extract(epoch FROM o.created_at)) AS position, pp.part
|
||||
FROM dtf_local.orders o
|
||||
JOIN dtf_local.order_files f ON f.order_id=o.id JOIN dtf_local.uploads u ON u.id=f.upload_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 o.state=ANY(%s) AND (%s::uuid[] IS NULL OR o.id=ANY(%s))
|
||||
AND (%s::timestamptz IS NULL OR o.created_at>=%s) AND o.cancelled_at IS NULL AND {FINAL_OK}
|
||||
UNION ALL
|
||||
SELECT o.id,o.state,o.number,p.item_index,pp.upload_id,u.object_key,u.name,
|
||||
COALESCE(o.queue_key, extract(epoch FROM o.created_at))
|
||||
COALESCE(o.queue_key, extract(epoch FROM o.created_at)), pp.part
|
||||
FROM dtf_local.orders o
|
||||
JOIN dtf_local.print_files p ON p.order_id=o.id
|
||||
JOIN dtf_local.print_parts pp ON pp.order_id=p.order_id AND pp.item_index=p.item_index
|
||||
@@ -68,7 +70,7 @@ def print_ready(c, states, only=None, paid_after=None):
|
||||
AND NOT EXISTS (SELECT 1 FROM dtf_local.order_files f WHERE f.order_id=o.id AND f.kind='final'
|
||||
AND f.active AND f.item_index=p.item_index)
|
||||
AND NOT EXISTS (SELECT 1 FROM dtf_local.order_files f WHERE f.order_id=o.id AND f.kind='correction')
|
||||
ORDER BY position,order_id,item_index,name''',
|
||||
ORDER BY position,order_id,item_index,part NULLS LAST,name''',
|
||||
(list(states), ids, ids, paid_after, paid_after, list(states), ids, ids, paid_after, paid_after)).fetchall()
|
||||
return rows
|
||||
|
||||
|
||||
Reference in New Issue
Block a user