Skip to content

Commit

Permalink
return fallbacks for total last_updated for v1 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
hbruch committed Jan 9, 2024
1 parent c7e4b3e commit fdf1f4b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions web/api_v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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,
})

0 comments on commit fdf1f4b

Please sign in to comment.