mirror of
https://github.com/reactos/web.git
synced 2024-11-27 05:30:22 +00:00
[TESTMAN]
- only generate the indicators once and store the images locally - browsers should now cache these - requested by Amine svn path=/trunk/; revision=830
This commit is contained in:
parent
1487ba64a3
commit
72090e2ce7
@ -58,6 +58,8 @@
|
||||
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
$indicator = new Indicator($row["id"]);
|
||||
|
||||
$table_summary .= '<th onmousedown="ResultHead_OnMouseDown(this)">';
|
||||
$table_summary .= sprintf($testman_langres["resulthead"], $row["revision"], GetDateString($row["timestamp"]), $row["name"], GetPlatformString($row["platform"]));
|
||||
$table_summary .= '</th>';
|
||||
@ -65,7 +67,7 @@
|
||||
$table_totals .= '<td>';
|
||||
$table_totals .= sprintf('<div title="%s" class="box totaltests totals">%s <span class="diff">%s</span></div>', $testman_langres["totaltests"], $row["count"], GetDifference($row, $prev_row, "count"));
|
||||
$table_totals .= sprintf('<div title="%s" class="box %s_failedtests totals">%d <span class="diff">%s</span></div>', $testman_langres["failedtests"], ($row["failures"] > 0 ? 'real' : 'zero'), $row["failures"], GetDifference($row, $prev_row, "failures"));
|
||||
$table_totals .= sprintf('<div class="healthindicator" onmouseover="HealthIndicator_OnMouseOver()" onmouseout="HealthIndicator_OnMouseOut()"><img src="indicator.php?id=%d" alt="healthindicator"/></div>',$row["id"]);
|
||||
$table_totals .= sprintf('<div class="healthindicator" onmouseover="HealthIndicator_OnMouseOver()" onmouseout="HealthIndicator_OnMouseOut()"><img src="%s" alt="healthindicator"/></div>', $indicator->imagePath);
|
||||
$table_totals .= '</td>';
|
||||
|
||||
$table_separator .= "<td> </td>";
|
||||
|
@ -9,6 +9,7 @@
|
||||
define("TESTMAN_PATH", realpath(__DIR__));
|
||||
define("ROOT_PATH", TESTMAN_PATH . "/../../../../../../");
|
||||
define("SHARED_PATH", ROOT_PATH . "drupal/sites/default/shared/");
|
||||
define("INDICATORS_PATH", "indicators/");
|
||||
|
||||
define("DEFAULT_SEARCH_LIMIT", 10);
|
||||
define("DEFAULT_SEARCH_SOURCE", "CMake_x86_GCCLin (KVM)");
|
||||
|
@ -101,4 +101,4 @@
|
||||
</div><br />
|
||||
|
||||
<iframe id="comparepage_frame" frameborder="0" onload="ResizeIFrame()" scrolling="yes"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,64 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
PROJECT: ReactOS Web Test Manager
|
||||
LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation
|
||||
PURPOSE: Health indicator
|
||||
COPYRIGHT: Copyright 2009 Alwyn Tan <alwyn.tan@gmail.com>
|
||||
*/
|
||||
|
||||
require_once("config.inc.php");
|
||||
require_once("connect.db.php");
|
||||
|
||||
function doColour(&$status, &$tests, &$failures)
|
||||
{
|
||||
if($status !== 'ok')
|
||||
return array(0,0,0);
|
||||
else if($failures >= $tests)
|
||||
return array(255,0,0);
|
||||
else if($failures == 0 || $tests == 0)
|
||||
return array(0,255,0);
|
||||
$offset = intval($failures * 255 / $tests);
|
||||
return array(255,255-$offset,0);
|
||||
}
|
||||
|
||||
if(empty($_GET['id']) || $_GET['id'] < 0)
|
||||
die("invalid id");
|
||||
$test_id=$_GET['id'];
|
||||
|
||||
try
|
||||
{
|
||||
$dbh = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_TESTMAN, DB_USER, DB_PASS);
|
||||
}
|
||||
catch(PDOException $e)
|
||||
{
|
||||
// Give no exact error message here, so no server internals are exposed
|
||||
die("<error>Could not establish the DB connection</error>");
|
||||
}
|
||||
|
||||
$height = 20;
|
||||
$resultwidth = 1;
|
||||
$width = 334;
|
||||
|
||||
$i = 0;
|
||||
$image = imagecreatetruecolor($width, $height);
|
||||
$colour = imagecolorallocate($image, 255, 255, 255);
|
||||
imagefill($image, 0, 0, $colour);
|
||||
|
||||
$stmt = $dbh->prepare("SELECT status, count, failures FROM winetest_results WHERE test_id = :test_id");
|
||||
$stmt->bindParam(":test_id",$test_id,PDO::PARAM_INT);
|
||||
$stmt->execute() or die("indicator DB error #1");
|
||||
|
||||
while($row = $stmt->fetch(PDO::FETCH_ASSOC))
|
||||
{
|
||||
$result = doColour($row["status"], $row["count"], $row["failures"]);
|
||||
$offset = $i * $resultwidth;
|
||||
$colour = imagecolorallocate($image,$result[0],$result[1],$result[2]);
|
||||
imagefilledrectangle($image,$offset,0,$offset + ($resultwidth-1),$height-1,$colour);
|
||||
|
||||
++$i;
|
||||
}
|
||||
|
||||
header('Content-Type: image/png');
|
||||
imagepng($image);
|
||||
imagedestroy($image);
|
||||
?>
|
0
www/www.reactos.org/drupal/sites/all/modules/reactos/testman/indicators/.gitignore
vendored
Normal file
0
www/www.reactos.org/drupal/sites/all/modules/reactos/testman/indicators/.gitignore
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/*
|
||||
PROJECT: ReactOS Web Test Manager
|
||||
LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation
|
||||
PURPOSE: Health indicator
|
||||
COPYRIGHT: Copyright 2009 Alwyn Tan <alwyn.tan@gmail.com>
|
||||
*/
|
||||
|
||||
require_once("config.inc.php");
|
||||
require_once("connect.db.php");
|
||||
|
||||
class Indicator
|
||||
{
|
||||
public $imagePath;
|
||||
private $id;
|
||||
|
||||
public function __construct($id)
|
||||
{
|
||||
if($id <= 0)
|
||||
die("invalid id");
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
$this->imagePath = INDICATORS_PATH."$id.png";
|
||||
|
||||
if(file_exists($this->imagePath))
|
||||
return;
|
||||
|
||||
$this->generateImage();
|
||||
}
|
||||
|
||||
private function doColour(&$status, &$tests, &$failures)
|
||||
{
|
||||
if($status !== 'ok')
|
||||
{
|
||||
return array(0, 0, 0);
|
||||
}
|
||||
else if($failures >= $tests)
|
||||
{
|
||||
return array(255, 0, 0);
|
||||
}
|
||||
else if($failures == 0 || $tests == 0)
|
||||
{
|
||||
return array(0, 255, 0);
|
||||
}
|
||||
|
||||
$offset = intval($failures * 255 / $tests);
|
||||
|
||||
return array(255, 255 - $offset, 0);
|
||||
}
|
||||
|
||||
private function generateImage()
|
||||
{
|
||||
try
|
||||
{
|
||||
$dbh = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_TESTMAN, DB_USER, DB_PASS);
|
||||
}
|
||||
catch(PDOException $e)
|
||||
{
|
||||
// Give no exact error message here, so no server internals are exposed
|
||||
die("<error>Could not establish the DB connection</error>");
|
||||
}
|
||||
|
||||
$height = 20;
|
||||
$resultwidth = 1;
|
||||
$width = 334;
|
||||
|
||||
$i = 0;
|
||||
$image = imagecreatetruecolor($width, $height);
|
||||
$colour = imagecolorallocate($image, 255, 255, 255);
|
||||
imagefill($image, 0, 0, $colour);
|
||||
|
||||
$stmt = $dbh->prepare("SELECT status, count, failures FROM winetest_results WHERE test_id = :test_id");
|
||||
$stmt->bindParam(":test_id", $this->id, PDO::PARAM_INT);
|
||||
$stmt->execute() or die("indicator DB error #1");
|
||||
|
||||
while($row = $stmt->fetch(PDO::FETCH_ASSOC))
|
||||
{
|
||||
$result = $this->doColour($row["status"], $row["count"], $row["failures"]);
|
||||
$offset = $i * $resultwidth;
|
||||
$colour = imagecolorallocate($image,$result[0],$result[1],$result[2]);
|
||||
imagefilledrectangle($image,$offset,0,$offset + ($resultwidth-1),$height-1,$colour);
|
||||
|
||||
++$i;
|
||||
}
|
||||
|
||||
imagepng($image, $this->imagePath);
|
||||
imagedestroy($image);
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user