fix: the print file is written over twice as fast, and a file finished after Prova OK queues its order (#81)
Some checks failed
Build and deploy / Validate source (push) Successful in 1m41s
Build and deploy / Publish images (push) Has been cancelled
Build and deploy / Secret scan and release gate (push) Has been cancelled
Build and deploy / Integration suite on a real stack (push) Has been cancelled
Some checks failed
Build and deploy / Validate source (push) Successful in 1m41s
Build and deploy / Publish images (push) Has been cancelled
Build and deploy / Secret scan and release gate (push) Has been cancelled
Build and deploy / Integration suite on a real stack (push) Has been cancelled
#81's 91,5 m took 6 hours to generate. The PNG writer ran Pillow's row filters and then deflate at level 6; no filter at level 1 gives the same size in under half the time, for the file and the viewer's strips alike (1 m: 34 s -> 13 s). Its Prova OK came while the file was still being generated, so the order stayed in Arte recebida. The approval now also runs when the file finishes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -205,35 +205,9 @@ def proof_answer(uid: UUID, body: ProofAnswer, user=Depends(can('proof'))):
|
||||
c.execute('''INSERT INTO dtf_local.movements(order_id,from_state,to_state,operator,reason)
|
||||
VALUES(%s,'rev','fin',%s,%s)''', (uid, user, label))
|
||||
if body.result == 'ok':
|
||||
# A prova aprovada é a conferência do pai: os arquivos completos
|
||||
# que o Prumo gerou entram como finais, e o pai segue para a fila.
|
||||
# Itens que ainda dependem de preparo manual continuam em Arte
|
||||
# recebida, com o botão de final disponível.
|
||||
if parent['state'] == 'rec' and not needs_designer(parent['snapshot']):
|
||||
generated = c.execute('''SELECT p.item_index,p.upload_id FROM dtf_local.print_files p
|
||||
WHERE p.order_id=%s AND p.status='ready' AND p.upload_id IS NOT NULL
|
||||
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.kind='final' AND f.active)
|
||||
ORDER BY p.item_index''', (parent['id'],)).fetchall()
|
||||
for row in generated:
|
||||
c.execute('''INSERT INTO dtf_local.order_files
|
||||
(id,order_id,upload_id,item_index,kind,note,created_by)
|
||||
VALUES(%s,%s,%s,%s,'final',%s,'Prumo')''',
|
||||
(uuid4(), parent['id'], row['upload_id'], row['item_index'],
|
||||
f'Aprovado pela prova do #{card["number"]}'))
|
||||
treatment_clause = f'AND {TREATED}' if needs_designer(parent['snapshot']) else ''
|
||||
ready = parent['state'] == 'rec' and all(c.execute(f'''SELECT 1 FROM dtf_local.order_files f
|
||||
JOIN dtf_local.orders o ON o.id=f.order_id
|
||||
JOIN dtf_local.uploads u ON u.id=f.upload_id
|
||||
WHERE f.order_id=%s AND f.item_index=%s AND {FINAL_OK}
|
||||
{treatment_clause} LIMIT 1''', (parent['id'], i)).fetchone()
|
||||
for i in range(len(parent['snapshot']['items'])))
|
||||
c.execute('''UPDATE dtf_local.orders SET proof_ok_at=now(), proof_ok_by=%s, version=version+1, updated_at=now(),
|
||||
state=CASE WHEN %s THEN 'tra' ELSE state END WHERE id=%s''', (user, ready, parent['id']))
|
||||
if ready:
|
||||
c.execute('''INSERT INTO dtf_local.movements(order_id,from_state,to_state,operator,reason)
|
||||
VALUES(%s,'rec','tra',%s,'Prova OK')''', (parent['id'], user))
|
||||
c.execute('''UPDATE dtf_local.orders SET proof_ok_at=now(), proof_ok_by=%s, version=version+1,
|
||||
updated_at=now() WHERE id=%s''', (user, parent['id']))
|
||||
proof.approve_parent(c, parent, user)
|
||||
elif parent['state'] in ('rec', 'tra') and not parent['cancelled_at']:
|
||||
# Back to Arte recebida with the reason; its final is approved again.
|
||||
c.execute("UPDATE dtf_local.order_files SET active=false WHERE order_id=%s AND kind='final'", (parent['id'],))
|
||||
|
||||
Reference in New Issue
Block a user