From: maxious Date: Fri, 25 Mar 2011 04:52:45 +0000 Subject: fix bug: route view should shownext trip to finish not next to start X-Git-Url: https://maxious.lambdacomplex.org/git/?p=busui.git&a=commitdiff&h=9fd8cca6c9b4477dd3f64beec9bc48faedbdd0e7 --- fix bug: route view should shownext trip to finish not next to start --- --- a/include/common-template.inc.php +++ b/include/common-template.inc.php @@ -121,13 +121,13 @@ echo " -
+
+ Back

' . $pageTitle . '

--- a/include/common.inc.php +++ b/include/common.inc.php @@ -5,7 +5,7 @@ "session", "json", "phperror", - "awsgtfs", + //"awsgtfs", "awsotp", //"squallotp", //"vanilleotp", --- a/schedule_viewer.py +++ b/schedule_viewer.py @@ -316,8 +316,19 @@ except: print "Error for GetStartTime of trip #" + t.trip_id + sys.exc_info()[0] else: - result.append ( (starttime, t.trip_id) ) - return sorted(result, key=lambda trip: trip[0]) + cursor = t._schedule._connection.cursor() + cursor.execute( + 'SELECT arrival_secs,departure_secs FROM stop_times WHERE ' + 'trip_id=? ORDER BY stop_sequence DESC LIMIT 1', (t.trip_id,)) + (arrival_secs, departure_secs) = cursor.fetchone() + if arrival_secs != None: + endtime = arrival_secs + elif departure_secs != None: + endtime = departure_secs + else: + endtime =0 + result.append ( (starttime, t.trip_id, endtime) ) + return sorted(result, key=lambda trip: trip[2]) def handle_json_GET_triprows(self, params): """Return a list of rows from the feed file that are related to this --- a/trip.php +++ b/trip.php @@ -9,7 +9,7 @@ $url = $APIurl . "/json/routetrips?route_id=" . $routeid; $routetrips = json_decode(getPage($url)); foreach ($routetrips as $trip) { - if ($trip[0] > midnight_seconds()) { + if ($trip[2] > midnight_seconds()) { $tripid = $trip[1]; break; }