Fixed bug where printer's hour counter was not updated, if backend was restarted

This commit is contained in:
maziggy
2026-01-06 08:50:59 +01:00
parent a1c69dc89d
commit c960b91f2a
+1 -7
View File
@@ -1626,8 +1626,7 @@ async def track_printer_runtime():
# Calculate time since last update
if printer.last_runtime_update:
elapsed = (now - printer.last_runtime_update).total_seconds()
# Sanity check: don't add more than 2x the interval (handles server restarts)
if elapsed > 0 and elapsed < RUNTIME_TRACKING_INTERVAL * 2:
if elapsed > 0:
printer.runtime_seconds += int(elapsed)
updated_count += 1
needs_commit = True
@@ -1635,11 +1634,6 @@ async def track_printer_runtime():
f"[{printer.name}] Runtime tracking: added {int(elapsed)}s, "
f"total={printer.runtime_seconds}s ({printer.runtime_seconds / 3600:.2f}h)"
)
else:
logger.warning(
f"[{printer.name}] Runtime tracking: skipped elapsed={elapsed:.1f}s "
f"(outside valid range 0-{RUNTIME_TRACKING_INTERVAL * 2}s)"
)
else:
# First time seeing printer active - need to commit to save timestamp
needs_commit = True