fix: Números shows no pace for under a quarter of an hour in Imprimindo
All checks were successful
Build and deploy / Validate source (push) Successful in 4s
Build and deploy / Integration suite on a real stack (push) Successful in 6m29s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m5s

A machine whose only finished order passed through Imprimindo in seconds
showed 110671,5 m per hour. The pace (per machine and month by month) now
needs at least 15 minutes of printing time and shows a dash below that.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-16 14:10:29 -03:00
parent 4f584fed8a
commit 66bc2b9b03
3 changed files with 28 additions and 4 deletions

View File

@@ -41,6 +41,17 @@ INK_ITEMS = tuple(item for item in SUPPLIES if item.startswith('ink_'))
# Average month, for the monthly contribution since installation.
_MONTH_SECONDS = Decimal('30.4375') * 86400
# Below a quarter of an hour in Imprimindo the pace is noise: an order moved
# through in seconds made a machine show 110671,5 m/h (16/11). No pace then.
MIN_PACE_HOURS = 0.25
def pace(metres, hours):
"""Metres per hour, one decimal; None below MIN_PACE_HOURS of printing."""
if not hours or float(hours) < MIN_PACE_HOURS:
return None
return round(float(metres) / float(hours), 1)
def month_bounds(month):
"""'2026-11' (None: the current month, local) -> (first day, first day of
@@ -79,8 +90,7 @@ def ratios(printed, hours_running=None, supplies_cents=0, parts_cents=0, rolls=N
return int((Decimal(cents) / printed).quantize(Decimal('1'), rounding=ROUND_HALF_UP))
result = {
'metres_per_hour': (round(float(printed) / float(hours_running), 1)
if hours_running else None),
'metres_per_hour': pace(printed, hours_running),
'metres_per_roll': round(float(printed / Decimal(str(rolls))), 1) if rolls else None,
'ink_per_100m': {
item: (None if quantity is None or not printed