USER = ".$_GET['USER']);
echo("
LIB_NAME = ".$_GET['LIB_NAME']);
echo("
branch = ".$_GET['branch']);
die("
die");
*/
header("Content-Type: image/svg+xml");
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date dans le passé
/*
header('Content-Type: image/svg+xml');
echo '';
*/
function errorSVG($_name) {
echo('');
exit();
}
include_once("connect.php");
@include_once("connect_server.php");
$COVERAGE_bdd = mysqli_connect($sqlServer, $sqlLogin, $sqlPass, $sqlBDD);
// Check connection
if (mysqli_connect_errno()) {
errorSVG("SQL ERROR");
}
// check if all is here ...
$branch = "master";
if (isset($_GET['USER']) == FALSE) {
errorSVG("USER??");
} else if (isset($_GET['LIB_NAME']) == FALSE) {
errorSVG("LIB_NAME??");
}
if (isset($_GET['branch']) == TRUE) {
$branch = $_GET['branch'];
}
//echo "register ".$_POST['JSON_FILE'];
$sql = "SELECT `COVERAGE_list`.`executed` "
." , `COVERAGE_list`.`executable` "
." FROM `COVERAGE_list`"
." , `CI_group`"
." WHERE `CI_group`.`user-name` = '".$_GET['USER']."'"
." AND `CI_group`.`lib-name` = '".$_GET['LIB_NAME']."'"
." AND `CI_group`.`lib-branch` = '".$branch."'"
." AND `CI_group`.`id` = `COVERAGE_list`.`id-group`"
." ORDER BY `COVERAGE_list`.`time` DESC"
." LIMIT 1";
$result = $COVERAGE_bdd->query($sql);
//echo("sql : ".$sql);
if ($result == NULL) {
errorSVG("UNKNOW");
}
//echo("find result : ".$result);
if ($result->num_rows > 0) {
if ($result->num_rows > 1) {
errorSVG("To much value");
}
$row = $result->fetch_assoc();
} else {
errorSVG("No Value");
}
if ($row['executable'] == 0) {
$coverage = 100;
} else {
$coverage = intval(100 * $row['executed'] / $row['executable']);
}
//some coverage value :
if ($coverage < 25 ) {
$color = "c11";
} else if ($coverage < 50 ) {
$color = "c1c";
} else if ($coverage < 75 ) {
$color = "c71";
} else {
$color = "4c1";
}
echo('');
// simply close link with the DB...
$COVERAGE_bdd->close();
?>