diff --git a/website/overview/data-suite.php b/website/overview/data-suite.php index 1cb90aa..d33d1b6 100644 --- a/website/overview/data-suite.php +++ b/website/overview/data-suite.php @@ -20,7 +20,6 @@ $results = mysql_query($query); if (!$results || mysql_num_rows($results) != 1) die(); $row = mysql_fetch_array($results); -$runId = $row[0]; $overview["machine"] = $machine; $overview["stamp"] = $row[1]; $overview["suiteVersion"] = $suiteVersion; @@ -36,16 +35,37 @@ if (!has_permissions()) { die(); } -$query = "SELECT id, mode_id FROM `awfy_build` - WHERE run_id = $runId"; +// Get all modes. +$query = "SELECT mode_id + FROM `awfy_build` + LEFT JOIN awfy_run ON run_id = awfy_run.id + WHERE machine = $machine + GROUP BY mode_id"; $results = mysql_query($query); if (!$results || mysql_num_rows($results) < 1) die(); $buildIds = Array(); $modeIds = Array(); +$stamps = Array(); while($row = mysql_fetch_array($results)) { - $buildIds[] = $row[0]; - $modeIds[] = $row[1]; + $mode = $row[0]; + + // Get last build of a specific mode (not older than 5 days from the newest result). + $query = "SELECT awfy_build.id, stamp FROM `awfy_build` + LEFT JOIN awfy_run ON run_id = awfy_run.id + WHERE awfy_build.mode_id = $mode AND + machine = $machine AND + stamp >= ".($overview["stamp"]-5*24*60*60)." AND + status = 1 + ORDER BY stamp DESC + LIMIT 1"; + $buildInfo = mysql_query($query) or die(mysql_error()); + if (!$buildInfo || mysql_num_rows($buildInfo) != 1) + continue; + $buildRow = mysql_fetch_array($buildInfo); + $buildIds[] = $buildRow[0]; + $modeIds[] = $mode; + $stamps[] = $buildRow[1]; } $data = Array(); @@ -69,7 +89,10 @@ while($row = mysql_fetch_array($tests)) { if (!$results || mysql_num_rows($results) != 1) continue; $row = mysql_fetch_array($results); - $scores[] = Array("buildid" => $buildIds[$j], "modeid" => $modeIds[$j], "score" => $row[0]); + $scores[] = Array("buildid" => $buildIds[$j], + "modeid" => $modeIds[$j], + "score" => $row[0], + "stamp" => $stamps[$j]); } $data[] = Array("suitetest" => $suiteTest, "scores" => $scores); } diff --git a/website/overview/data.php b/website/overview/data.php index c526aa7..5db64cd 100644 --- a/website/overview/data.php +++ b/website/overview/data.php @@ -13,7 +13,8 @@ init_database(); $machine = (int)$_GET["machine"]; $overview = Array(); -$query = "SELECT id, stamp FROM `awfy_run` +// Overall date. +$query = "SELECT stamp FROM `awfy_run` WHERE machine = $machine AND status = 1 ORDER BY stamp DESC @@ -22,20 +23,40 @@ $results = mysql_query($query); if (!$results || mysql_num_rows($results) != 1) die(); $row = mysql_fetch_array($results); -$runId = $row[0]; $overview["machine"] = $machine; -$overview["stamp"] = $row[1]; +$overview["stamp"] = $row[0]; -$query = "SELECT id, mode_id FROM `awfy_build` - WHERE run_id = $runId"; +// Get all modes. +$query = "SELECT mode_id + FROM `awfy_build` + LEFT JOIN awfy_run ON run_id = awfy_run.id + WHERE machine = $machine + GROUP BY mode_id"; $results = mysql_query($query); if (!$results || mysql_num_rows($results) < 1) die(); $buildIds = Array(); $modeIds = Array(); +$stamps = Array(); while($row = mysql_fetch_array($results)) { - $buildIds[] = $row[0]; - $modeIds[] = $row[1]; + $mode = $row[0]; + + // Get last build of a specific mode (not older than 5 days from the newest result). + $query = "SELECT awfy_build.id, stamp FROM `awfy_build` + LEFT JOIN awfy_run ON run_id = awfy_run.id + WHERE awfy_build.mode_id = $mode AND + machine = $machine AND + stamp >= ".($overview["stamp"]-5*24*60*60)." AND + status = 1 + ORDER BY stamp DESC + LIMIT 1"; + $buildInfo = mysql_query($query) or die(mysql_error()); + if (!$buildInfo || mysql_num_rows($buildInfo) != 1) + continue; + $buildRow = mysql_fetch_array($buildInfo); + $buildIds[] = $buildRow[0]; + $modeIds[] = $mode; + $stamps[] = $buildRow[1]; } $query = "SELECT suite_version_id FROM `awfy_score` @@ -71,7 +92,10 @@ for ($i=0; $i < count($suiteIds); $i++) { if (!$results || mysql_num_rows($results) != 1) continue; $row = mysql_fetch_array($results); - $scores[] = Array("buildid" => $buildIds[$j], "modeid" => $modeIds[$j], "score" => $row[0]); + $scores[] = Array("buildid" => $buildIds[$j], + "modeid" => $modeIds[$j], + "score" => $row[0], + "stamp" => $stamps[$j]); } $data[] = Array("suiteversionid" => $suiteIds[$i], "scores" => $scores); }