@@ -27,18 +27,19 @@ def update_recent_sightings():
2727 all_vehicles = asyncio .run (mbta_api .vehicle_data_for_routes (ROUTES ))
2828 new_vehicles = filter_new (all_vehicles )
2929
30- for vehicle in new_vehicles :
31- line = get_line_for_route (vehicle ["route" ])
32- last_seen_times [line ] = {
33- "car" : vehicle ["label" ],
34- "time" : now .isoformat (),
35- }
36- s3 .upload (JSON_PATH , json .dumps (last_seen_times ), compress = False )
30+ if new_vehicles :
31+ for vehicle in new_vehicles :
32+ line = get_line_for_route (vehicle ["route" ])
33+ last_seen_times [line ] = {
34+ "car" : vehicle ["label" ],
35+ "time" : now .isoformat (),
36+ }
37+ s3 .upload (JSON_PATH , json .dumps (last_seen_times ), compress = False )
3738 except Exception as e :
3839 print ("Couldn't write last seen times to s3: " , e )
3940
4041
4142# Get the last time that a new train was seen on each line
4243# This is the function that other modules use
4344def get_recent_sightings_for_lines ():
44- return json .loads (s3 .download (JSON_PATH , "utf8" ))
45+ return json .loads (s3 .download (JSON_PATH , "utf8" , compressed = False ))
0 commit comments