Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ETA Fixes #31

Open
wants to merge 3 commits into
base: 0.3.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions passiogo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ class Route:

def __init__(
self,
id: str,
id: int,
groupId: int = None,
groupColor: str = None,
name: str = None,
Expand Down Expand Up @@ -686,8 +686,7 @@ def getNextVehicle(
if not etas:
return None

# Generally operates in O(1) as etas come sorted by API
return min(etas, key = lambda x : x[0])
return etas[0]

def getEtas(
self,
Expand All @@ -710,12 +709,12 @@ def getEtas(
if str(self.id) not in data:
return vehicles
for vehicle in data[str(self.id)]:
if vehicle["etaR"]: #etaR is "" when eta is unavailable
if "etaR" in vehicle and vehicle["etaR"]: #etaR is "" when eta is unavailable
if returnInUTC:
eta = convertToUnixEta(vehicle["secondsSpent"])
else:
eta = vehicle["secondsSpent"]
vehicles.append((eta, self.system.getVehicleById(int(vehicle["busId"]))))
vehicles.append((eta, self.system.getVehicleById(int(vehicle["busId"]))))
return vehicles


Expand Down