fix: a transfer asks which part the new machine resumes from and names the old machine's .prt to delete (Marcus, 2026-12-01)
The hot folder takes a PNG in about 10 s and the Hoson queues it, so the last part taken is not the one being ripped. The dialog lists the parts (already taken or still in the folder) and asks where to resume once any was taken; the new round starts there, and the parts from there on that the old machine took are named as Hoson .prt files to delete, in the toast, the card and the history. The film card no longer claims which part prints: '2/3 partes com a máquina'. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -113,22 +113,45 @@ def stop(c, order_id):
|
||||
WHERE order_id=%s AND state IN ('queued','claimed','written')''', (order_id,))
|
||||
|
||||
|
||||
def transfer(c, order_id):
|
||||
"""The order changed machine in Imprimindo (Rodada 5, D4): the old machine
|
||||
keeps what Flexi already took, and what it had not leaves its folder; the
|
||||
new one starts from the part the old was ripping, in a new round."""
|
||||
def last_round(c, order_ids):
|
||||
"""Each order's parts in its last round, in order: {order id: [{seq, name,
|
||||
state}]}, for the transfer dialog to ask where the new machine resumes."""
|
||||
rows = c.execute('''SELECT h.order_id, h.seq, h.name, h.state FROM dtf_local.hot_parts h
|
||||
WHERE h.order_id=ANY(%s) AND h.round=(SELECT max(round) FROM dtf_local.hot_parts x
|
||||
WHERE x.order_id=h.order_id) ORDER BY h.order_id, h.seq''', (list(order_ids),)).fetchall()
|
||||
out = {}
|
||||
for row in rows:
|
||||
out.setdefault(row['order_id'], []).append({'seq': row['seq'], 'name': row['name'], 'state': row['state']})
|
||||
return out
|
||||
|
||||
|
||||
def prt_name(name):
|
||||
"""The Hoson file the RIP makes from a part: its name with .prt."""
|
||||
return name.rsplit('.', 1)[0] + '.prt'
|
||||
|
||||
|
||||
def transfer(c, order_id, resume_from=None):
|
||||
"""The order changed machine in Imprimindo (Rodada 5, D4). The hot folder
|
||||
takes a PNG in about 10 s (Marcus, 2026-12-01), so a part the old machine
|
||||
took may still be waiting in its Hoson queue: Gestão says which part the
|
||||
new machine resumes from. The old machine's folder loses what it had not
|
||||
taken; the new round holds that part onward. Returns (resume_from, the
|
||||
.prt files to delete from the old machine's Hoson folder: the parts from
|
||||
there on that it had already taken)."""
|
||||
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 1
|
||||
taken = c.execute('''SELECT max(seq) AS s FROM dtf_local.hot_parts
|
||||
WHERE order_id=%s AND round=%s AND state='consumed' ''', (order_id, last)).fetchone()['s']
|
||||
return 1, []
|
||||
parts = c.execute('''SELECT seq, name, state FROM dtf_local.hot_parts WHERE order_id=%s AND round=%s
|
||||
ORDER BY seq''', (order_id, last)).fetchall()
|
||||
start = resume_from or 1
|
||||
delete = [prt_name(part['name']) for part in parts if part['seq'] >= start and part['state'] == 'consumed']
|
||||
stop(c, order_id)
|
||||
c.execute('''INSERT INTO dtf_local.hot_parts(order_id,round,seq,item_index,upload_id,name)
|
||||
SELECT order_id, %s, row_number() OVER (ORDER BY seq), item_index, upload_id, name
|
||||
FROM dtf_local.hot_parts WHERE order_id=%s AND round=%s AND seq >= %s''',
|
||||
(last + 1, order_id, last, taken or 1))
|
||||
return taken or 1
|
||||
(last + 1, order_id, last, start))
|
||||
return start, delete
|
||||
|
||||
|
||||
def claim(c, user):
|
||||
@@ -194,9 +217,10 @@ def report(c, part_id, what, user):
|
||||
|
||||
|
||||
def progress(c, order_ids):
|
||||
"""For each order in parts, where its film is (Dropstar, 2026-10-30):
|
||||
"parte 3/7 imprimindo · 4/7 ripando". Flexi rips the part it took last
|
||||
while the one before it prints."""
|
||||
"""For each order in parts, how many of its parts the machine took
|
||||
(Dropstar, 2026-10-30). The hot folder takes a PNG in about 10 s and the
|
||||
Hoson queues it (Marcus, 2026-12-01): a part taken may still wait to be
|
||||
ripped, so nothing here says which part prints."""
|
||||
rows = c.execute('''SELECT h.order_id, count(*) AS parts,
|
||||
max(h.seq) FILTER (WHERE h.state='consumed') AS taken,
|
||||
count(*) FILTER (WHERE h.state IN ('claimed','written')) AS waiting
|
||||
|
||||
Reference in New Issue
Block a user