Skip to content

Commit 296cb97

Browse files
committed
log implausible delays
1 parent 8c644cb commit 296cb97

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

vehicles/rtpi.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# "Real Time Passenger Information"-ish stuff - calculating delays etc
22

33
import datetime
4+
import logging
45
from itertools import pairwise
56
from django.contrib.gis.geos import LineString, Point
67
from django.contrib.gis.db.models.functions import Distance, LineLocatePoint
@@ -10,6 +11,9 @@
1011
from vehicles.utils import calculate_bearing
1112

1213

14+
logger = logging.getLogger(__name__)
15+
16+
1317
def get_route_bearing(geometry: LineString, progress: float):
1418
"""Get the bearing of the route at a given progress point (0-1)."""
1519
delta = 0.01
@@ -187,6 +191,9 @@ def get_progress(item: dict, stop_time=None) -> Progress | None:
187191
if abs(alt.delay) < abs(progress.delay):
188192
progress = alt
189193

194+
if abs(progress.delay) > 43200: # more than 12 hours
195+
logger.warning("%s delay is %s", item, progress.delay)
196+
190197
return progress
191198

192199

0 commit comments

Comments
 (0)