mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-09 15:35:39 +02:00
Fixed bug where printer's hour counter was not updated, if backend was restarted
This commit is contained in:
+1
-7
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user