kadamwhite / mbtawesome

An MBTA subway status application with a good attitude
http://www.mbtawesome.com
MIT License
11 stars 0 forks source link

Average wait shows as NaN when no trains are running #27

Open kadamwhite opened 9 years ago

kadamwhite commented 9 years ago

When the T is shut down or service has ended for the night, average wait times display as NaN. The average wait time should not be displayed if no service is available

kadamwhite commented 9 years ago

image

Sample JSON:


{"route_id":"Red","route_name":"Red Line","route_type":"1","mode_name":"Subway","direction":[{"direction_id":"1","direction_name":"Northbound","trip":[{"trip_id":"26259811","trip_name":"10:09 am from Ashmont - Inbound to Alewife","trip_headsign":"Alewife","vehicle":{"vehicle_id":"1819","vehicle_lat":"42.36147","vehicle_lon":"-71.07437","vehicle_bearing":"275","vehicle_timestamp":"1427553641"},"stop":[{"stop_sequence":"12","stop_id":"70072","stop_name":"Kendall/MIT - Outbound","sch_arr_dt":"1427553240","sch_dep_dt":"1427553240","pre_dt":"1427554015","pre_away":"46"},{"stop_sequence":"13","stop_id":"70070","stop_name":"Central - Outbound","sch_arr_dt":"1427553360","sch_dep_dt":"1427553360","pre_dt":"1427554167","pre_away":"198"}]},{"trip_id":"26259635","trip_name":"10:19 am from Braintree to Alewife","trip_headsign":"Alewife","vehicle":{"vehicle_id":"1804","vehicle_lat":"42.33107","vehicle_lon":"-71.057","vehicle_bearing":"0","vehicle_timestamp":"1427553635"},"stop":[{"stop_sequence":"8","stop_id":"70082","stop_name":"Broadway - Inbound","sch_arr_dt":"1427553900","sch_dep_dt":"1427553900","pre_dt":"1427554007","pre_away":"38"},{"stop_sequence":"9","stop_id":"70080","stop_name":"South Station - Inbound","sch_arr_dt":"1427554020","sch_dep_dt":"1427554020","pre_dt":"1427554161","pre_away":"192"},{"stop_sequence":"10","stop_id":"70078","stop_name":"Downtown Crossing - to Alewife","sch_arr_dt":"1427554140","sch_dep_dt":"1427554140","pre_dt":"1427554248","pre_away":"279"},{"stop_sequence":"11","stop_id":"70076","stop_name":"Park Street - to Alewife","sch_arr_dt":"1427554260","sch_dep_dt":"1427554260","pre_dt":"1427554341","pre_away":"372"},{"stop_sequence":"12","stop_id":"70074","stop_name":"Charles/MGH - Outbound","sch_arr_dt":"1427554380","sch_dep_dt":"1427554380","pre_dt":"1427554521","pre_away":"552"},{"stop_sequence":"13","stop_id":"70072","stop_name":"Kendall/MIT - Outbound","sch_arr_dt":"1427554500","sch_dep_dt":"1427554500","pre_dt":"1427554685","pre_away":"716"},{"stop_sequence":"14","stop_id":"70070","stop_name":"Central - Outbound","sch_arr_dt":"1427554620","sch_dep_dt":"1427554620","pre_dt":"1427554837","pre_away":"868"}]},{"trip_id":"26259930","trip_name":"10:37 am from Ashmont - Inbound to Alewife","trip_headsign":"Alewife","vehicle":{"vehicle_id":"1843","vehicle_lat":"42.31624","vehicle_lon":"-71.05217","vehicle_bearing":"350","vehicle_timestamp":"1427553934"},"stop":[{"stop_sequence":"5","stop_id":"70086","stop_name":"JFK/UMASS Ashmont - Inbound","sch_arr_dt":"1427554020","sch_dep_dt":"1427554020","pre_dt":"1427553969","pre_away":"0"},{"stop_sequence":"6","stop_id":"70084","stop_name":"Andrew - Inbound","sch_arr_dt":"1427554200","sch_dep_dt":"1427554200","pre_dt":"1427554122","pre_away":"153"},{"stop_sequence":"7","stop_id":"70082","stop_name":"Broadway - Inbound","sch_arr_dt":"1427554320","sch_dep_dt":"1427554320","pre_dt":"1427554260","pre_away":"291"},{"stop_sequence":"8","stop_id":"70080","stop_name":"South Station - Inbound","sch_arr_dt":"1427554440","sch_dep_dt":"1427554440","pre_dt":"1427554414","pre_away":"445"},{"stop_sequence":"9","stop_id":"70078","stop_name":"Downtown Crossing - to Alewife","sch_arr_dt":"1427554560","sch_dep_dt":"1427554560","pre_dt":"1427554501","pre_away":"532"},{"stop_sequence":"10","stop_id":"70076","stop_name":"Park Street - to Alewife","sch_arr_dt":"1427554680","sch_dep_dt":"1427554680","pre_dt":"1427554594","pre_away":"625"},{"stop_sequence":"11","stop_id":"70074","stop_name":"Charles/MGH - Outbound","sch_arr_dt":"1427554800","sch_dep_dt":"1427554800","pre_dt":"1427554774","pre_away":"805"},{"stop_sequence":"12","stop_id":"70072","stop_name":"Kendall/MIT - Outbound","sch_arr_dt":"1427554920","sch_dep_dt":"1427554920","pre_dt":"1427554938","pre_away":"969"},{"stop_sequence":"13","stop_id":"70070","stop_name":"Central - Outbound","sch_arr_dt":"1427555040","sch_dep_dt":"1427555040","pre_dt":"1427555090","pre_away":"1121"}]},{"trip_id":"26259672","trip_name":"10:47 am from Braintree to Alewife","trip_headsign":"Alewife","vehicle":{"vehicle_id":"1878","vehicle_lat":"42.23337","vehicle_lon":"-71.00682","vehicle_bearing":"15","vehicle_timestamp":"1427553958"},"stop":[{"stop_sequence":"3","stop_id":"70102","stop_name":"Quincy Center - Inbound","sch_arr_dt":"1427554440","sch_dep_dt":"1427554440","pre_dt":"1427554140","pre_away":"171"},{"stop_sequence":"4","stop_id":"70100","stop_name":"Wollaston - Inbound","sch_arr_dt":"1427554620","sch_dep_dt":"1427554620","pre_dt":"1427554322","pre_away":"353"},{"stop_sequence":"5","stop_id":"70098","stop_name":"North Quincy - Inbound","sch_arr_dt":"1427554740","sch_dep_dt":"1427554740","pre_dt":"1427554460","pre_away":"491"},{"stop_sequence":"6","stop_id":"70096","stop_name":"JFK/UMASS Braintree - Inbound","sch_arr_dt":"1427555280","sch_dep_dt":"1427555280","pre_dt":"1427554950","pre_away":"981"},{"stop_sequence":"7","stop_id":"70084","stop_name":"Andrew - Inbound","sch_arr_dt":"1427555460","sch_dep_dt":"1427555460","pre_dt":"1427555125","pre_away":"1156"},{"stop_sequence":"8","stop_id":"70082","stop_name":"Broadway - Inbound","sch_arr_dt":"1427555580","sch_dep_dt":"1427555580","pre_dt":"1427555263","pre_away":"1294"},{"stop_sequence":"9","stop_id":"70080","stop_name":"South Station - Inbound","sch_arr_dt":"1427555700","sch_dep_dt":"1427555700","pre_dt":"1427555417","pre_away":"1448"},{"stop_sequence":"10","stop_id":"70078","stop_name":"Downtown Crossing - to Alewife","sch_arr_dt":"1427555820","sch_dep_dt":"1427555820","pre_dt":"1427555504","pre_away":"1535"},{"stop_sequence":"11","stop_id":"70076","stop_name":"Park Street - to Alewife","sch_arr_dt":"1427555940","sch_dep_dt":"1427555940","pre_dt":"1427555597","pre_away":"1628"},{"stop_sequence":"12","stop_id":"70074","stop_name":"Charles/MGH - Outbound","sch_arr_dt":"1427556060","sch_dep_dt":"1427556060","pre_dt":"1427555777","pre_away":"1808"},{"stop_sequence":"13","stop_id":"70072","stop_name":"Kendall/MIT - Outbound","sch_arr_dt":"1427556180","sch_dep_dt":"1427556180","pre_dt":"1427555941","pre_away":"1972"},{"stop_sequence":"14","stop_id":"70070","stop_name":"Central - Outbound","sch_arr_dt":"1427556300","sch_dep_dt":"1427556300","pre_dt":"1427556093","pre_away":"2124"}]}]}],"alert_headers":[{"alert_id":67562,"header_text":"Buses replacing Red Line service between Alewife and Harvard Square Stations on March 28-29 from start to end of service.","effect_name":"Shuttle"},{"alert_id":71012,"header_text":"Red Line experiencing moderate delays due to a disabled train at Harvard.","effect_name":"Delay"}]}