feat: migrate displayed historical data to postgres

This commit is contained in:
devRaGonSa
2026-05-21 09:27:08 +02:00
parent c6420d5968
commit 605ab92cf8
17 changed files with 1719 additions and 25 deletions

View File

@@ -3,6 +3,7 @@
from __future__ import annotations
import json
from datetime import date, datetime
from http import HTTPStatus
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
@@ -38,7 +39,7 @@ class HealthHandler(BaseHTTPRequestHandler):
return
def _write_json(self, status: HTTPStatus, payload: dict[str, object]) -> None:
body = json.dumps(payload).encode("utf-8")
body = json.dumps(payload, default=_json_default).encode("utf-8")
self.send_response(status)
self._send_default_headers(content_length=len(body))
self.end_headers()
@@ -61,6 +62,13 @@ def create_server() -> ThreadingHTTPServer:
return ThreadingHTTPServer((host, port), HealthHandler)
def _json_default(value: object) -> str:
"""Serialize PostgreSQL date/time values before they can abort an HTTP response."""
if isinstance(value, (date, datetime)):
return value.isoformat()
raise TypeError(f"Object of type {type(value).__name__} is not JSON serializable")
def run() -> None:
"""Start the local bootstrap server."""
host, port = get_bind_address()