Travelling all routes thought experiment
Travelling all routes thought experiment

file:b/.box (new)
--- /dev/null
+++ b/.box
@@ -1,1 +1,5 @@
+shared_writable_dirs:
+    - /labs/tiles
+    - /lib/staticmaplite/cache
+php_extensions: [pgsql, pdo, pdo_pgsql, curl]
 

--- a/include/common-template.inc.php
+++ b/include/common-template.inc.php
@@ -34,6 +34,8 @@
 <meta name="viewport" content="width=device-width, initial-scale=1"> 	
 <title>' . $pageTitle . '</title>
         <meta name="google-site-verification" content="-53T5Qn4TB_de1NyfR_ZZkEVdUNcNFSaYKSFkWKx-sY" />
+<link rel="dns-prefetch" href="//code.jquery.com">
+<link rel="dns-prefetch" href="//ajax.googleapis.com">
 	<link rel="stylesheet"  href="' . $labsPath . 'css/jquery-ui-1.8.12.custom.css" />';
 	if (isDebugServer()) {
 		$jqmcss = $labsPath . 'css/jquery.mobile-1.0b1.css';
@@ -41,9 +43,9 @@
 		$jqmjs = $labsPath . 'js/jquery.mobile-1.0b1.js';
 	}
 	else {
-		$jqmcss = "http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.css";
-		$jqjs = "http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js";
-		$jqmjs = "http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.js";
+		$jqmcss = "//code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.css";
+		$jqjs = "//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js";
+		$jqmjs = "//code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.js";
 	}
 	echo '<link rel="stylesheet"  href="' . $jqmcss . '" />
 	<script src="'.$jqjs.'"></script>

--- a/include/db/trip-dao.inc.php
+++ b/include/db/trip-dao.inc.php
@@ -173,6 +173,22 @@
 	$r = $query->fetch(PDO::FETCH_ASSOC);
 	return $r['arrival_time'];
 }
+function getTripEndTime($tripID)
+{
+	global $conn;
+	$query = "SELECT trip_id,max(arrival_time) as arrival_time from stop_times
+	WHERE stop_times.arrival_time IS NOT NULL and trip_id = :tripID group by trip_id";
+	debug($query, "database");
+	$query = $conn->prepare($query);
+	$query->bindParam(":tripID", $tripID);
+	$query->execute();
+	if (!$query) {
+		databaseError($conn->errorInfo());
+		return Array();
+	}
+	$r = $query->fetch(PDO::FETCH_ASSOC);
+	return $r['arrival_time'];
+}
 function getActiveTrips($time)
 {
 	global $conn;

--- /dev/null
+++ b/labs/travelAllRoutes.php
@@ -1,1 +1,23 @@
+<?php
+include ('../include/common.inc.php');
+	$query = "Select route_short_name,max(route_id) as route_id from routes where route_short_name NOT LIKE '7__'  AND route_short_name != '170' AND route_short_name NOT LIKE '9__' group by route_short_name order by route_short_name ;";
+	debug($query, "database");
+	$query = $conn->prepare($query);
+	$query->execute();
+echo "<table><tr><th>Route Number</th><th>First Trip Start</th><th>First Trip End</th><th>Length</th>";
+$total = 0;
+$count = 0;
+foreach($query->fetchAll() as $r) {
+        $trips = getRouteTrips($r['route_id']);
+    $startTime = $trips[0]['arrival_time'];
+    $endTime = getTripEndTime($trips[0]['trip_id']);
+    $timeDiff = strtotime($endTime) - strtotime($startTime);
+    $total += $timeDiff;
+    $count ++;
+    echo "<tr><td>{$r['route_short_name']}</td><td>$startTime</td><td>$endTime</td><td>$timeDiff seconds ie. ". ($timeDiff/60). " minutes</td></tr>";
 
+}
+echo "</table>";
+echo "Total time: $total seconds ie. " .($total/60/60). " hours<br>";
+echo "$count Routes";
+?>