fix: Números measures what Dropstar asked: machines by film printed, stages by order
All checks were successful
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Successful in 3m23s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m7s

- a machine's metres are the film printed, not the metres billed, which round
  up to one metre and made small orders look like fast printing
- orders in Imprimindo together on one machine count that time once
- a stage's median time is per order, the sum of its passages, so rework
  reads as one slow order instead of quick passages

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-22 15:25:08 -03:00
parent 80975b9424
commit 3ae453f47a
5 changed files with 80 additions and 19 deletions

View File

@@ -4,6 +4,7 @@ Run against the local stack: python3 -m tests.kanban_test
"""
import base64
import secrets
from datetime import date, timedelta
from urllib.error import HTTPError
from urllib.parse import urlencode
from urllib.request import Request
@@ -144,6 +145,18 @@ def run():
tra_before = after['stages'].get('tra', {'orders': 0, 'passages': 0})
assert moved['stages']['tra']['orders'] == tra_before['orders'] + 1, moved['stages']
assert moved['stages']['tra']['passages'] == tra_before['passages'] + 2, moved['stages']
# Its time in a stage is the sum of its passages: on a day of its own, one
# hour in Arte conferida, a correction, and another hour there read as 2 h.
alone = (date(2001, 1, 1) + timedelta(days=int(tag, 16) % 3000)).isoformat()
with db.connect() as c:
c.execute('UPDATE dtf_local.orders SET created_at=%s::timestamptz WHERE id=%s', (f'{alone} 08:00-03', order_id))
c.execute('DELETE FROM dtf_local.movements WHERE order_id=%s', (order_id,))
for hour, (frm, to) in enumerate((('rec', 'tra'), ('tra', 'cor'), ('cor', 'tra'), ('tra', 'fil')), start=9):
c.execute('''INSERT INTO dtf_local.movements(order_id,from_state,to_state,operator,reason,back,created_at)
VALUES(%s,%s,%s,'kanban-test','',false,%s::timestamptz)''', (order_id, frm, to, f'{alone} {hour}:00-03'))
day = client.call(f'/operator/stats?start={alone}&end={alone}', operator=True)
assert day['stages']['tra'] == {'orders': 1, 'passages': 2, 'median_hours': 2.0}, day['stages']
assert day['stages']['rec']['median_hours'] == 1.0, day['stages']
# The company's name from the registry: on the board, and found by the search.
from app import cnpj as registry