Guard day_track call with function-existence check (order-independent deploy)
Some checks are pending
build / lint-test (push) Waiting to run
build / build-push (push) Blocked by required conditions

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
kianiadee 2026-05-29 10:32:59 +03:00
parent e89d8ed821
commit 34afe60927

View file

@ -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(
"SELECT to_regprocedure('serve.fn_vehicle_day_track(bigint, date)') IS NOT NULL"
)
exists_row = await cur.fetchone()
if exists_row and exists_row[0]:
await cur.execute( await cur.execute(
"SELECT serve.fn_vehicle_day_track(%s, %s)", (vehicle_id, day) "SELECT serve.fn_vehicle_day_track(%s, %s)", (vehicle_id, day)
) )
track_row = await cur.fetchone() track_row = await cur.fetchone()
payload["day_track"] = track_row[0] if track_row and track_row[0] is not None else None track = track_row[0] if track_row else None
payload["day_track"] = track
return payload return payload