Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buildmaster/statistics.php108
1 files changed, 53 insertions, 55 deletions
diff --git a/buildmaster/statistics.php b/buildmaster/statistics.php
index 097be80..f867973 100644
--- a/buildmaster/statistics.php
+++ b/buildmaster/statistics.php
@@ -1,59 +1,59 @@
<?php
-require_once "../init.php";
-require_once BASE . "/lib/mysql.php";
+require_once '../init.php';
+require_once BASE . '/lib/mysql.php';
-if (array_key_exists("from", $_GET))
- $min_time="from_base64(\"" . base64_encode("-".$_GET["from"]) . "\")";
+if (array_key_exists('from', $_GET))
+ $min_time = 'from_base64("' . base64_encode('-' . $_GET['from']) . '")';
else
- $min_time="\"-7 00:00:00\"";
+ $min_time='"-7 00:00:00"';
-if (array_key_exists("arch", $_GET))
- $arch_filter = arch_filter_query("architectures");
+if (array_key_exists('arch', $_GET))
+ $arch_filter = arch_filter_query('architectures');
else
- $arch_filter = "1";
+ $arch_filter = '1';
$column_list = array(
- "pending_tasks_count",
- "pending_packages_count",
- "staging_packages_count",
- "testing_packages_count",
- "tested_packages_count",
- "broken_tasks_count",
- "dependency_loops_count",
- "dependency_looped_tasks_count",
- "locked_tasks_count",
- "blocked_tasks_count",
- "next_tasks_count"
+ 'pending_tasks_count',
+ 'pending_packages_count',
+ 'staging_packages_count',
+ 'testing_packages_count',
+ 'tested_packages_count',
+ 'broken_tasks_count',
+ 'dependency_loops_count',
+ 'dependency_looped_tasks_count',
+ 'locked_tasks_count',
+ 'blocked_tasks_count',
+ 'next_tasks_count'
);
function combine_column($name) {
- return "SUM(`statistics`.`" . $name . "`) AS `" . $name . "`";
+ return 'SUM(`statistics`.`' . $name . '`) AS `' . $name . '`';
}
$result = mysql_run_query(
- "SELECT DISTINCT".
- " UNIX_TIMESTAMP(`statistics`.`date`) AS `date`," .
- implode(",", array_map("combine_column", $column_list)) .
- " FROM `statistics`" .
- " JOIN `architectures` ON `statistics`.`architecture`=`architectures`.`id`" .
- " WHERE `statistics`.`date`>=ADDDATE(NOW()," . $min_time . ")" .
- " AND " . $arch_filter .
- " GROUP BY `statistics`.`date`" .
- " ORDER BY `statistics`.`date`"
+ 'SELECT DISTINCT'.
+ ' UNIX_TIMESTAMP(`statistics`.`date`) AS `date`,' .
+ implode(',', array_map('combine_column', $column_list)) .
+ ' FROM `statistics`' .
+ ' JOIN `architectures` ON `statistics`.`architecture`=`architectures`.`id`' .
+ ' WHERE `statistics`.`date`>=ADDDATE(NOW(),' . $min_time . ')' .
+ ' AND ' . $arch_filter .
+ ' GROUP BY `statistics`.`date`' .
+ ' ORDER BY `statistics`.`date`'
);
$t_min = -1;
$t_max = -1;
$val_max = -1;
-while($vals = $result->fetch_assoc()) {
+while($vals = $result -> fetch_assoc()) {
if ($t_min == -1)
- $t_min = $vals["date"];
- $t_max = $vals["date"];
+ $t_min = $vals['date'];
+ $t_max = $vals['date'];
foreach ($vals as $column => $val)
- if ($column != "date") {
- $values[$column][$vals["date"]] = $val;
- $val_max = max($val_max,$val);
+ if ($column != 'date') {
+ $values[$column][$vals['date']] = $val;
+ $val_max = max($val_max, $val);
}
};
$print_columns = array_keys($values);
@@ -72,7 +72,7 @@ $legend_line_length = 10;
$legend_height = 2 * ImageFontHeight(5) + $legend_line_length;
$im = @ImageCreate ($width + $legend_line_length + $max_len * ImageFontWidth(5), $height + $legend_height)
- or die ("Cannot create new gd-image-stream");
+ or die ('Cannot create new gd-image-stream');
$background_color = ImageColorAllocate ($im, 255, 255, 255);
$foreground_color = ImageColorAllocate ($im, 0, 0, 0);
@@ -115,10 +115,10 @@ function print_graph($data, $color) {
if ($last_t != -1)
ImageLine(
$im,
- scale($last_t,$t_min,$t_max,$width-2*$border,false)+$border+$legend_line_length,
- scale($last_val,0,$val_max,-$height+2*$border,array_key_exists("log", $_GET))+$border,
- scale($t,$t_min,$t_max,$width-2*$border,false)+$border+$legend_line_length,
- scale($val,0,$val_max,-$height+2*$border,array_key_exists("log", $_GET))+$border,
+ scale($last_t, $t_min, $t_max, $width - 2*$border, false) + $border + $legend_line_length,
+ scale($last_val, 0, $val_max, -$height + 2*$border, array_key_exists('log', $_GET)) + $border,
+ scale($t, $t_min, $t_max, $width - 2*$border, false) + $border + $legend_line_length,
+ scale($val, 0, $val_max, -$height + 2*$border, array_key_exists('log', $_GET)) + $border,
$color
);
$last_t = $t;
@@ -127,20 +127,20 @@ function print_graph($data, $color) {
ImageString(
$im,
5,
- $width+$legend_line_length,
- scale($last_val,0,$val_max,-$height+2*$border,array_key_exists("log", $_GET))+$border - ImageFontHeight(5)/2,
- " ".$data[$t_max],
+ $width + $legend_line_length,
+ scale($last_val, 0, $val_max, -$height + 2*$border, array_key_exists('log', $_GET)) + $border - ImageFontHeight(5)/2,
+ ' ' . $data[$t_max],
$color
);
};
-ImageRectangle($im, $legend_line_length, 0, $width-1+$legend_line_length, $height-1, $foreground_color);
+ImageRectangle($im, $legend_line_length, 0, $width-1 + $legend_line_length, $height-1, $foreground_color);
$xpos = $legend_line_length;
foreach ($print_columns as $column) {
print_graph($values[$column], $colors[$column]);
ImageString($im, 5, $xpos, $height + $legend_line_length + ImageFontHeight(5), substr($column,0,-strlen("_count")), $colors[$column]);
- $xpos += (strlen($column) - strlen("_count") + 1.75) * ImageFontWidth(5);
+ $xpos += (strlen($column) - strlen('_count') + 1.75) * ImageFontWidth(5);
}
ImageString($im, 5, $legend_line_length, $height + $legend_line_length, date('Y-m-d H:i', $t_min), $foreground_color);
@@ -157,27 +157,25 @@ for ($t=ceil($t_min/24/60/60); $t<=floor($t_max/24/60/60); $t++)
$foreground_color
);
-for ($val=0; $val<=$val_max;) {
+for ($val = 0; $val <= $val_max;) {
ImageLine(
$im,
0,
- scale($val,0,$val_max,-$height+2*$border,array_key_exists("log", $_GET))+$border,
+ scale($val, 0, $val_max, -$height + 2*$border, array_key_exists('log', $_GET)) + $border,
$legend_line_length,
- scale($val,0,$val_max,-$height+2*$border,array_key_exists("log", $_GET))+$border,
+ scale($val, 0, $val_max, -$height + 2*$border, array_key_exists('log', $_GET)) + $border,
$foreground_color
);
- if (! array_key_exists("log", $_GET))
- $val+=pow(10,round(log($val_max)/log(10))-1);
- elseif ($val==0)
+ if (! array_key_exists('log', $_GET))
+ $val+=pow(10, round(log($val_max) / log(10)) - 1);
+ elseif ($val == 0)
$val++;
else
- $val=$val*10;
+ $val = $val*10;
}
// ImageString ($im, 1, 5, 5, "Test-String ".rand(), $foreground_color);
-header ("Content-type: image/png");
+header ('Content-type: image/png');
ImagePNG ($im);
-
-?>