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
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:
@@ -5,6 +5,7 @@ from decimal import Decimal
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
|
||||
from ... import machines, payments, unpaid
|
||||
from ...machine_stats import pace
|
||||
from ...cart_pricing import designer_hours
|
||||
from ...core import db
|
||||
from ...core.auth import operator
|
||||
@@ -336,7 +337,7 @@ def machine_output(c, start, end):
|
||||
made = float(sum(row['metres'] for row in mine))
|
||||
result.append({'id': m['id'], 'name': m['name'], 'active': m['active'], 'orders': len(mine),
|
||||
'metres': made, 'printing_hours': round(hours_in, 2),
|
||||
'metres_per_hour': round(made / hours_in, 1) if hours_in > 0 else None,
|
||||
'metres_per_hour': pace(made, hours_in),
|
||||
'last_finished': last[m['id']].isoformat() if m['id'] in last else None,
|
||||
'now': {state: m['states'].get(state, 0) for state in ('tra', 'imp')}})
|
||||
loose = [row for row in done if row['machine_id'] is None]
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user