From fa2323ba924d306b8991f874fc7b3fea165fb5a6 Mon Sep 17 00:00:00 2001 From: Holger Bruch Date: Sun, 10 Dec 2023 15:57:37 +0100 Subject: [PATCH] return fallbacks for total last_updated for v1 compatibility --- web/api_v1/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web/api_v1/views.py b/web/api_v1/views.py index be280c8..cccdc34 100644 --- a/web/api_v1/views.py +++ b/web/api_v1/views.py @@ -187,7 +187,8 @@ def get(self, request: Request, city: str): "name": lot.name, "region": None, # TODO "state": None, - "total": lot.max_capacity, + # ParkAPI v1 requires total, so we return 0 if unknown + "total": lot.max_capacity if lot.max_capacity else 0, } if lot.latest_data: api_lot.update({ @@ -209,7 +210,9 @@ def get(self, request: Request, city: str): return Response({ "last_downloaded": last_downloaded, - "last_updated": last_updated, + # v1 schema requires last_updated to be set. If it's not available, + # we fall back to (somewhat misleading) last_downloaded + "last_updated": last_updated if last_updated else last_downloaded, "lots": api_lot_list, })