From 72e00ae7813adbde39bc59d17227c599e2ff8333 Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Sat, 10 Feb 2024 20:35:00 +0100 Subject: [PATCH] Take delay into account in the next departures/arrivals tables --- sncf/api/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sncf/api/views.py b/sncf/api/views.py index 73b5306..30d15ad 100644 --- a/sncf/api/views.py +++ b/sncf/api/views.py @@ -177,14 +177,14 @@ class NextDeparturesViewSet(viewsets.ReadOnlyModelViewSet): ~Q(update__departure_time=datetime.fromtimestamp(0))) qs_today = StopTime.objects.filter(stop_filter) \ - .filter(Q(departure_time__gte=query_time)) \ + .filter(Q(departure_time__gte=query_time - F('update__departure_delay'))) \ .filter(Q(pickup_type=0) | canceled_filter(query_date)) \ .filter(calendar_filter(query_date)) \ .annotate(departure_date=Value(query_date)) \ .annotate(departure_time_24h=F('departure_time')) qs_yesterday = StopTime.objects.filter(stop_filter) \ - .filter(Q(departure_time__gte=time_yesterday)) \ + .filter(Q(departure_time__gte=time_yesterday - F('update__departure_delay'))) \ .filter(Q(pickup_type=0) | canceled_filter(yesterday)) \ .filter(calendar_filter(yesterday)) \ .annotate(departure_date=Value(yesterday)) \ @@ -249,14 +249,14 @@ class NextArrivalsViewSet(viewsets.ReadOnlyModelViewSet): ~Q(update__arrival_time=datetime.fromtimestamp(0))) qs_today = StopTime.objects.filter(stop_filter) \ - .filter(Q(departure_time__gte=query_time)) \ + .filter(Q(departure_time__gte=query_time - F('update__arrival_delay'))) \ .filter(Q(drop_off_type=0) | canceled_filter(query_date)) \ .filter(calendar_filter(query_date)) \ .annotate(arrival_date=Value(query_date)) \ .annotate(arrival_time_24h=F('arrival_time')) qs_yesterday = StopTime.objects.filter(stop_filter) \ - .filter(Q(departure_time__gte=time_yesterday)) \ + .filter(Q(departure_time__gte=time_yesterday - F('update__arrival_delay'))) \ .filter(Q(drop_off_type=0) | canceled_filter(yesterday)) \ .filter(calendar_filter(yesterday)) \ .annotate(arrival_date=Value(yesterday)) \