Guard day_track call with function-existence check (order-independent deploy)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
e89d8ed821
commit
34afe60927
1 changed files with 12 additions and 4 deletions
|
|
@ -73,12 +73,20 @@ async def _fetch_trips(vehicle_id: int, day: date) -> dict[str, Any]:
|
||||||
# Continuous day track (GeoJSON LineString of every fix, in order) so the
|
# Continuous day track (GeoJSON LineString of every fix, in order) so the
|
||||||
# frontend can draw one unbroken route under the per-trip coloured
|
# frontend can draw one unbroken route under the per-trip coloured
|
||||||
# segments — trip splits on reporting gaps no longer look like the
|
# segments — trip splits on reporting gaps no longer look like the
|
||||||
# vehicle teleported.
|
# vehicle teleported. Guarded by an existence check so the endpoint keeps
|
||||||
|
# working if the code is deployed before migration 24 lands.
|
||||||
|
track: Any = None
|
||||||
await cur.execute(
|
await cur.execute(
|
||||||
"SELECT serve.fn_vehicle_day_track(%s, %s)", (vehicle_id, day)
|
"SELECT to_regprocedure('serve.fn_vehicle_day_track(bigint, date)') IS NOT NULL"
|
||||||
)
|
)
|
||||||
track_row = await cur.fetchone()
|
exists_row = await cur.fetchone()
|
||||||
payload["day_track"] = track_row[0] if track_row and track_row[0] is not None else None
|
if exists_row and exists_row[0]:
|
||||||
|
await cur.execute(
|
||||||
|
"SELECT serve.fn_vehicle_day_track(%s, %s)", (vehicle_id, day)
|
||||||
|
)
|
||||||
|
track_row = await cur.fetchone()
|
||||||
|
track = track_row[0] if track_row else None
|
||||||
|
payload["day_track"] = track
|
||||||
return payload
|
return payload
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue