Skip to content
This repository
Browse code

Only show departures in the next 2 hours

  • Loading branch information...
commit 88ff96f4ca86f23fed711f36e311e96cad07d350 1 parent c633fff
Chris Northwood cnorthwood authored

Showing 1 changed file with 7 additions and 3 deletions. Show diff stats Hide diff stats

  1. +7 3 molly/apps/places/providers/timetables.py
10 molly/apps/places/providers/timetables.py
... ... @@ -1,5 +1,5 @@
1 1 from collections import namedtuple, defaultdict
2   -from datetime import datetime, time
  2 +from datetime import datetime, time, timedelta
3 3 from logging import getLogger
4 4 from operator import itemgetter
5 5
@@ -38,8 +38,12 @@ def midnight_4am(left, right):
38 38 continue
39 39
40 40 services = defaultdict(list)
41   - for stop in entity.scheduledstop_set.filter(
42   - Q(sta__gte=today.time()) | Q(sta__lt=time(4))):
  41 + if today.time() < time(22):
  42 + until = [Q(sta__gte=today.time()) | Q(std__gte=today.time()), Q(sta__lt=(today + timedelta(hours=2)).time()) | Q(std__lt=(today + timedelta(hours=2)).time())]
  43 + else:
  44 + until = [Q(sta__gte=today.time()) | Q(std__gte=today.time()) | Q(sta__lt=(today + timedelta(hours=2)).time()) | Q(std__lt=(today + timedelta(hours=2)).time())]
  45 +
  46 + for stop in entity.scheduledstop_set.filter(*until):
43 47
44 48 if not stop.journey.runs_on(today.date()):
45 49 continue

0 comments on commit 88ff96f

Please sign in to comment.
Something went wrong with that request. Please try again.