feat: Redesenho previews on the server: one at a time, counted, and the stage clock stops while one waits (Rodada 5, D2)
POST /api/operator/orders/{id}/redesign-preview (sent, approved,
rejected), redesign_previews table, previews on every board order, and
assign_late leaves out the time a preview waited for the customer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -137,7 +137,15 @@ def assign_late(c, orders, limits):
|
||||
if not since and order['state'] == 'fin':
|
||||
since = order.get('finished_at')
|
||||
since = since or order['created_at']
|
||||
hours = max(0.0, (now - since).total_seconds() / 3600)
|
||||
hours = (now - since).total_seconds() / 3600
|
||||
# A preview waiting for the customer stops the stage clock: the time
|
||||
# between sending it and its answer is left out (D2).
|
||||
for preview in order.get('previews') or []:
|
||||
if preview['sent_at'] < since:
|
||||
continue
|
||||
ended = preview['decided_at'] or now
|
||||
hours -= max(0.0, (ended - preview['sent_at']).total_seconds() / 3600)
|
||||
hours = max(0.0, hours)
|
||||
limit_hours = float(limit['hours'])
|
||||
# Paid designer work gives Art received its extra hours to prepare the
|
||||
# art: 48 h for a Redesenho, 24 h for the basic Ajuste Fino.
|
||||
@@ -207,6 +215,10 @@ def with_print_files(c, orders):
|
||||
# Why each order was last sent to correction, for the notice to the customer.
|
||||
reasons = {row['order_id']: row['reason'] for row in c.execute('''SELECT DISTINCT ON (order_id) order_id,reason
|
||||
FROM dtf_local.movements WHERE order_id=ANY(%s) AND to_state='cor' ORDER BY order_id,id DESC''', (ids,)).fetchall()}
|
||||
# A redesign's previews, oldest first: the card shows them and the stage
|
||||
# clock leaves out the time a preview waited for the customer (D2).
|
||||
previews = c.execute('''SELECT order_id,number,sent_at,sent_by,decided_at,result,reason,decided_by
|
||||
FROM dtf_local.redesign_previews WHERE order_id=ANY(%s) ORDER BY order_id,number''', (ids,)).fetchall()
|
||||
# Where a printing order's files are in its machine's hot folder (item 10).
|
||||
hot = hotfolder.progress(c, [o['id'] for o in orders if o['state'] == 'imp'])
|
||||
# Orders the machine already printed: a reprint chooses which items go
|
||||
@@ -252,6 +264,9 @@ def with_print_files(c, orders):
|
||||
order['corrections'] = [{k: row[k] for k in ('item_index', 'upload_id', 'name', 'expired')}
|
||||
for row in fixes if row['order_id'] == order['id']]
|
||||
order['reworks'] = [row for row in reworks if row['order_id'] == order['id']]
|
||||
order['previews'] = [{k: row[k] for k in ('number', 'sent_at', 'sent_by', 'decided_at', 'result',
|
||||
'reason', 'decided_by')}
|
||||
for row in previews if row['order_id'] == order['id']]
|
||||
return assign_machines(c, orders)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user