Disk-based caching for spots so they survive a software restart

This commit is contained in:
Ian Renton
2025-10-04 09:12:40 +01:00
parent bfcaf6e261
commit c785137258
5 changed files with 29 additions and 35 deletions

View File

@@ -16,10 +16,10 @@ from core.utils import serialize_everything
class WebServer:
# Constructor
def __init__(self, spot_list, status_data, port):
def __init__(self, spots, status_data, port):
self.last_page_access_time = None
self.last_api_access_time = None
self.spot_list = spot_list
self.spots = spots
self.status_data = status_data
self.port = port
self.thread = Thread(target=self.run)
@@ -90,7 +90,11 @@ class WebServer:
# value or a comma-separated list.
# We can provide a "limit" number as well. Spots are always returned newest-first; "limit" limits to only the
# most recent X spots.
spots = sorted(self.spot_list, key=lambda spot: spot.time, reverse=True)
spot_guids = list(self.spots.iterkeys())
spots = []
for k in spot_guids:
spots.append(self.spots.get(k))
spots = sorted(spots, key=lambda spot: spot.time, reverse=True)
for k in query.keys():
match k:
case "since":