Format average station-station time nicely.
authorCMDR furrycat <elite@furrycat.net>
Mon, 8 Feb 2016 15:23:22 +0000 (10:23 -0500)
committerCMDR furrycat <elite@furrycat.net>
Mon, 8 Feb 2016 15:23:22 +0000 (10:23 -0500)
lib/race.php
race.js

index 6af77c8..6435544 100644 (file)
           "type" => "bar"
         )
       );
+      $raced_times = array(
+        "raced_times" => array(
+          "x" => array(),
+          "y" => array(),
+          "name" => "Time raced",
+          "type" => "bar"
+        )
+      );
       $dbh = Propel::getConnection();
       /* Average station to station speed. */
       $sth = $dbh->prepare("select s1.name as station1, s2.name as station2, avg(timestampdiff(second, l1.arrival, l2.arrival)) as delta from laptime l1, laptime l2, station s1, station s2, lap, entry, course where l1.lap_id=l2.lap_id and l1.station_id=s1.id and l2.station_id=s2.id and l1.lap_id=lap.id and lap.entry_id=entry.id and course.race_id=entry.race_id and l2.station_order=l1.station_order+1 and entry.race_id=:race_id group by station1, station2 order by delta");
       $sth->execute(array(":race_id" => $id));
       while ($row = $sth->fetch()) {
         $legs["leg_times"]["x"][] = sprintf("%s - %s", $row["station1"], $row["station2"]);
-        $legs["leg_times"]["y"][] = (int) $row["delta"];
+        $legs["leg_times"]["y"][] = "2000-01-01 " . format_time((int) $row["delta"]);
       }
       /* Average station to station speed. */
       $sth = $dbh->prepare("select s1.name as station1, s2.name as station2, avg((distance / (timestampdiff(second, l1.arrival, l2.arrival) / 3600))) as speed from laptime l1, laptime l2, station s1, station s2, lap, entry, course, raikogram where l1.lap_id=l2.lap_id and l1.station_id=s1.id and l2.station_id=s2.id and l1.lap_id=lap.id and lap.entry_id=entry.id and system1=(select case when s1.system_id<s2.system_id then s1.system_id else s2.system_id end) and system2=(select case when s1.system_id<s2.system_id then s2.system_id else s1.system_id end) and course.race_id=entry.race_id and l2.station_order=l1.station_order+1 and entry.race_id=:race_id group by station1, station2 order by speed desc");
diff --git a/race.js b/race.js
index 7c09805..87128c8 100644 (file)
--- a/race.js
+++ b/race.js
@@ -157,7 +157,7 @@ function loaded() {
   canvas = document.getElementById('plot_legs');
   if (canvas && legs) Plotly.plot(canvas, legs, {
     title: 'Average station to station time',
-    yaxis: { title: 'Time (s)' }
+    yaxis: { title: 'Time', tickformat: '%H:%M:%S' }
   });
   canvas = document.getElementById('plot_speeds');
   if (canvas && speeds) Plotly.plot(canvas, speeds, {