From f60d1acf472b9d1e6495796a90a20c686d157306 Mon Sep 17 00:00:00 2001 From: CMDR furrycat Date: Mon, 8 Feb 2016 10:23:22 -0500 Subject: [PATCH] Format average station-station time nicely. --- lib/race.php | 10 +++++++++- race.js | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/race.php b/lib/race.php index 6af77c8..6435544 100644 --- a/lib/race.php +++ b/lib/race.php @@ -785,13 +785,21 @@ "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