From 65957b4c017fa80c2631d9d12bf28220da3a2686 Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Sun, 18 Jan 2026 07:52:06 +0000 Subject: [PATCH] Fix a bug where the "last updated time"/"last spot time" of providers that have never updated would be sent as a large negative number and represented on the web UI as e.g. "2026 years ago". --- core/status_reporter.py | 6 +++--- webassets/apidocs/openapi.yml | 6 +++--- webassets/js/status.js | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/status_reporter.py b/core/status_reporter.py index 91a4808..47cedf9 100644 --- a/core/status_reporter.py +++ b/core/status_reporter.py @@ -47,13 +47,13 @@ class StatusReporter: self.status_data["spot_providers"] = list( map(lambda p: {"name": p.name, "enabled": p.enabled, "status": p.status, "last_updated": p.last_update_time.replace( - tzinfo=pytz.UTC).timestamp() if p.last_update_time else 0, + tzinfo=pytz.UTC).timestamp() if p.last_update_time.year > 2000 else 0, "last_spot": p.last_spot_time.replace( - tzinfo=pytz.UTC).timestamp() if p.last_spot_time else 0}, self.spot_providers)) + tzinfo=pytz.UTC).timestamp() if p.last_spot_time.year > 2000 else 0}, self.spot_providers)) self.status_data["alert_providers"] = list( map(lambda p: {"name": p.name, "enabled": p.enabled, "status": p.status, "last_updated": p.last_update_time.replace( - tzinfo=pytz.UTC).timestamp() if p.last_update_time else 0}, + tzinfo=pytz.UTC).timestamp() if p.last_update_time.year > 2000 else 0}, self.alert_providers)) self.status_data["cleanup"] = {"status": self.cleanup_timer.status, "last_ran": self.cleanup_timer.last_cleanup_time.replace( diff --git a/webassets/apidocs/openapi.yml b/webassets/apidocs/openapi.yml index cbdaf53..5e3806a 100644 --- a/webassets/apidocs/openapi.yml +++ b/webassets/apidocs/openapi.yml @@ -1234,11 +1234,11 @@ components: example: OK last_updated: type: number - description: The last time at which this provider received data, UTC seconds since UNIX epoch. + description: The last time at which this provider received data, UTC seconds since UNIX epoch. If this is zero, the spot provider has never updated. example: 1759579508 last_spot: type: number - description: The time of the latest spot received by this provider, UTC seconds since UNIX epoch. + description: The time of the latest spot received by this provider, UTC seconds since UNIX epoch. If this is zero, the spot provider has never received a spot that was accepted by the system. example: 1759579508 AlertProviderStatus: @@ -1257,7 +1257,7 @@ components: example: OK last_updated: type: number - description: The last time at which this provider received data, UTC seconds since UNIX epoch. + description: The last time at which this provider received data, UTC seconds since UNIX epoch. If this is zero, the alert provider has never updated. example: 1759579508 Band: diff --git a/webassets/js/status.js b/webassets/js/status.js index 8c3794a..9b10cb5 100644 --- a/webassets/js/status.js +++ b/webassets/js/status.js @@ -22,14 +22,14 @@ function loadStatus() { jsonData["spot_providers"].forEach(p => { $("#status-container").append(generateStatusCard("Spot Provider: " + p["name"], [ `Status: ${p["status"]}`, - `Last Updated: ${p["enabled"] ? moment.unix(p["last_updated"]).utc().fromNow() : "N/A"}`, - `Latest Spot: ${p["enabled"] ? moment.unix(p["last_spot"]).utc().fromNow() : "N/A"}` + `Last Updated: ${(p["enabled"] && p["last_updated"] > 0) ? moment.unix(p["last_updated"]).utc().fromNow() : "N/A"}`, + `Latest Spot: ${(p["enabled"] && p["last_spot"] > 0) ? moment.unix(p["last_spot"]).utc().fromNow() : "N/A"}` ])); }); jsonData["alert_providers"].forEach(p => { $("#status-container").append(generateStatusCard("Alert Provider: " + p["name"], [ `Status: ${p["status"]}`, - `Last Updated: ${p["enabled"] ? moment.unix(p["last_updated"]).utc().fromNow() : "N/A"}` + `Last Updated: ${(p["enabled"] && p["last_updated"] > 0) ? moment.unix(p["last_updated"]).utc().fromNow() : "N/A"}` ])); }); });