fix: a reprint keeps an all-items choice, an undone pass to Revisão prints nothing again, and Prova OK tells Tiny (#105)
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 7m56s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m26s

- Every item ticked was saved as NULL, which also means "not chosen", so the
  pass to the queue replaced it with the suggestion and only the changed
  item went to the machine; the panel showed the suggestion again. The
  choice is now the whole list.
- Undoing a pass to Revisão (back to Imprimindo) started a new round with
  every file, so FlexiPRINT printed the order again. It now writes back only
  what Flexi had not taken, and the reprint choice of that pass returns. A
  pass undone this way no longer counts its film twice in the machine's
  metres (machine log and Números).
- An order entering the queue by Prova OK never sent Tiny's "Preparando
  envio". The stage's Tiny event is now one function, used by the move and
  by the Prova OK.

Integration test follows the real moves: suggestion, all items kept, pull
onto a machine, two undone passes to Revisão, metres counted once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-27 14:48:34 -03:00
parent 194797c412
commit f35a347a28
10 changed files with 166 additions and 49 deletions

View File

@@ -15,7 +15,8 @@ the same file and Flexi never prints it twice. A claim that did not finish
goes back to the queue. A written part that is gone from its folder was
taken by Flexi, and is never written again. A card that leaves Imprimindo
(Revisão, Correção, a step back, a cancellation) withdraws what Flexi has not
taken yet, and its computer deletes it.
taken yet, and its computer deletes it. A step back from Revisão to
Imprimindo writes again only what Flexi had not taken (resume()).
Each part's life is one row of dtf_local.hot_parts:
queued -> claimed -> written -> consumed, or withdraw -> gone.
@@ -70,6 +71,19 @@ def start(c, order_id):
VALUES(%s,%s,%s,%s,%s,%s)''', (order_id, round_, seq, row['item_index'], row['upload_id'], row['name']))
def resume(c, order_id):
"""A step back from Revisão to Imprimindo, undoing a move made by
mistake: the parts of the last round Flexi had not taken go back to the
folder, in their order; what it took was printed and is never written
again (start() would send the whole order to the machine once more)."""
last = c.execute('SELECT max(round) AS r FROM dtf_local.hot_parts WHERE order_id=%s', (order_id,)).fetchone()['r']
if last is None:
return
c.execute('''INSERT INTO dtf_local.hot_parts(order_id,round,seq,item_index,upload_id,name)
SELECT order_id, round + 1, row_number() OVER (ORDER BY seq), item_index, upload_id, name
FROM dtf_local.hot_parts WHERE order_id=%s AND round=%s AND state<>'consumed' ''', (order_id, last))
def printed(c, order_ids):
"""The files each order's machine has already taken, {order id: {upload
ids}}: an order in it was printed before."""