fix: review of phase-2 stage 0 and fronts 5, 6 and 11
All checks were successful
Build and deploy / Publish images (push) Successful in 1m5s
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 5m7s
Build and deploy / Secret scan and release gate (push) Successful in 6s

- A paid treatment adds its 24 h to Arte recebida's acceptable time, on
  the card and in Números (fronts 5 and 11).
- TINY_PRODUCT_TREATMENT is a required Tiny setting once the treatment
  has a price, instead of every treated order failing at the Tiny.
- A quote reads each PDF once: Files caches the header and the DPI.
- A proof made from the parent's final split into parts uses the part
  that holds the finest stroke, not the last one (0.1).
- Prumo report: one format line per item, the time from the claim (kept
  on the finished print file), and the stroke class in customer words.
- The Site says the Prumo checks the art, and a too-tall PNG no longer
  says "Este PDF".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-09 10:45:43 -03:00
parent 5a51084c8f
commit 5aafd9ee91
11 changed files with 227 additions and 37 deletions

View File

@@ -262,6 +262,10 @@ def assign_late(c, orders, limits):
since = since or order['created_at']
hours = max(0.0, (now - since).total_seconds() / 3600)
limit_hours = float(limit['hours'])
# A paid treatment gives Art received its extra hours to prepare the art.
treatment = (order.get('snapshot') or {}).get('treatment') or {}
if order['state'] == 'rec' and treatment:
limit_hours += float(treatment.get('hours', 24))
order['state_hours'] = round(hours, 2)
order['limit_hours'] = limit_hours
order['limit_by'] = limit['responsible']
@@ -1426,10 +1430,14 @@ def production_stats(days: int | None = Query(default=None, ge=7, le=365), start
FROM dtf_local.orders o WHERE {REAL_ORDER} AND o.state<>'fin' GROUP BY o.state''').fetchall()
# Passages past each stage's acceptable time (front 11), in the
# selected period and today.
late_rows = c.execute(f'''SELECT state,
extract(epoch FROM until-at) - {waited('s.id', 's.at', 's.until')} AS seconds,
(until AT TIME ZONE 'America/Sao_Paulo')::date AS day
FROM ({spans}) s WHERE until IS NOT NULL''', period + period).fetchall()
# Each passage carries whether its order paid for treatment, which only
# Art received counts (front 5).
late_rows = c.execute(f'''SELECT s.state,
extract(epoch FROM s.until-s.at) - {waited('s.id', 's.at', 's.until')} AS seconds,
(s.until AT TIME ZONE 'America/Sao_Paulo')::date AS day,
o.snapshot->'treatment' AS treatment
FROM ({spans}) s LEFT JOIN dtf_local.orders o ON o.id=s.id WHERE s.until IS NOT NULL''',
period + period).fetchall()
printed = machine_output(c, start, end)
# Rework of the period (D-02 to D-04): the authorized ones, by the day
# they were opened, over the film the machines printed in it.
@@ -1513,7 +1521,13 @@ def production_stats(days: int | None = Query(default=None, ge=7, le=365), start
late = {state: {'count': 0, 'today': 0} for state in ('rec', 'tra', 'imp', 'rev', 'fin')}
for row in late_rows:
limit = limits.get(row['state'])
if limit and row['seconds'] > limit['hours'] * 3600:
if not limit:
continue
hours = float(limit['hours'])
treatment = row.get('treatment') or {}
if row['state'] == 'rec' and treatment:
hours += float(treatment.get('hours', 24))
if row['seconds'] > hours * 3600:
late[row['state']]['count'] += 1
if row['day'] == today:
late[row['state']]['today'] += 1