Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/web-scripts
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-03-20 11:28:28 +0100
committerErich Eckner <git@eckner.net>2018-03-20 11:28:28 +0100
commit85201f7de2d131aba3c4e10852aed3e11f39fa0a (patch)
tree5da4718d8e8d6d2b45fbe4e7d1cbe567c31cb9a6 /web-scripts
parentbd5173dc0c845e0e01de8aed01bd85b0e6646344 (diff)
web-scripts/statistics.php: take info from database
Diffstat (limited to 'web-scripts')
-rw-r--r--web-scripts/statistics.php100
1 files changed, 45 insertions, 55 deletions
diff --git a/web-scripts/statistics.php b/web-scripts/statistics.php
index 279aa39..1e4d89b 100644
--- a/web-scripts/statistics.php
+++ b/web-scripts/statistics.php
@@ -1,54 +1,44 @@
<?php
-$columns = array(
- 'stable',
- 'tasks',
- 'pending_packages',
- 'staging',
- 'testing',
- 'broken',
- 'loops',
- 'looped_packages',
- 'locked',
- 'blocked',
- 'next_pending',
- 'tested'
-);
-
-$print_columns = array(
- 'tasks',
- 'pending_packages',
- 'staging',
- 'testing',
- 'tested',
- 'broken',
- 'loops',
- 'looped_packages',
- 'locked',
- 'blocked',
- 'next_pending'
-);
+$mysql = new mysqli("localhost", "webserver", "empty", "buildmaster");
+if ($mysql->connect_error) {
+ die("Connection failed: " . $mysql->connect_error);
+}
+if (! $result = $mysql -> query(
+ "SELECT DISTINCT ".
+ "UNIX_TIMESTAMP(`statistics`.`date`) AS `date`," .
+ "`statistics`.`pending_tasks_count`," .
+ "`statistics`.`pending_packages_count`," .
+ "`statistics`.`staging_packages_count`," .
+ "`statistics`.`testing_packages_count`," .
+ "`statistics`.`tested_packages_count`," .
+ "`statistics`.`broken_tasks_count`," .
+ "`statistics`.`dependency_loops_count`," .
+ "`statistics`.`dependency_looped_tasks_count`," .
+ "`statistics`.`locked_tasks_count`," .
+ "`statistics`.`blocked_tasks_count`," .
+ "`statistics`.`next_tasks_count`" .
+ "FROM `statistics` " .
+ "WHERE `statistics`.`date`>=ADDTIME(NOW(),\"-7 00:00:00\") " .
+ "ORDER BY `statistics`.`date`"
+ ))
+ die($mysql->error);
$t_min = -1;
$t_max = -1;
$val_max = -1;
-foreach (explode("\n",trim(file_get_contents('/srv/http/statistics'))) as $val) {
- $val = explode(" ",$val);
- if (($t_min == -1) || ($t_min > $val[0]))
- $t_min = $val[0];
- if (($t_max == -1) || ($t_max < $val[0]))
- $t_max = $val[0];
- foreach ($columns as $id => $column) {
- if (count($val) > $id+1)
- $values[$column][$val[0]] = $val[$id+1];
- };
- foreach ($print_columns as $column) {
- if (array_key_exists($column,$values))
- if (($val_max == -1) || ($val_max < $values[$column][$val[0]]))
- $val_max = $values[$column][$val[0]];
- }
+while($vals = $result->fetch_assoc()) {
+ if ($t_min == -1)
+ $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);
+ }
};
+$print_columns = array_keys($values);
$max_len = 0;
foreach ($print_columns as $column) {
@@ -69,18 +59,18 @@ $im = @ImageCreate ($width + $legend_line_length + $max_len * ImageFontWidth(5),
$background_color = ImageColorAllocate ($im, 255, 255, 255);
$foreground_color = ImageColorAllocate ($im, 0, 0, 0);
-$colors['stable'] = ImageColorAllocate ($im, 0, 0, 0);
-$colors['tasks'] = ImageColorAllocate ($im, 0, 0, 128);
-$colors['pending_packages'] = ImageColorAllocate ($im, 0, 0, 255);
-$colors['staging'] = ImageColorAllocate ($im, 0, 100, 0);
-$colors['testing'] = ImageColorAllocate ($im, 0, 200, 0);
-$colors['tested'] = ImageColorAllocate ($im, 100, 255, 0);
-$colors['broken'] = ImageColorAllocate ($im, 255, 0, 0);
-$colors['loops'] = ImageColorAllocate ($im, 128, 128, 0);
-$colors['looped_packages'] = ImageColorAllocate ($im, 255, 128, 128);
-$colors['locked'] = ImageColorAllocate ($im, 128, 128, 128);
-$colors['blocked'] = ImageColorAllocate ($im, 128, 0, 0);
-$colors['next_pending'] = ImageColorAllocate ($im, 0, 255, 255);
+$colors['stable_packages_count'] = ImageColorAllocate ($im, 0, 0, 0);
+$colors['pending_tasks_count'] = ImageColorAllocate ($im, 0, 0, 128);
+$colors['pending_packages_count'] = ImageColorAllocate ($im, 0, 0, 255);
+$colors['staging_packages_count'] = ImageColorAllocate ($im, 0, 100, 0);
+$colors['testing_packages_count'] = ImageColorAllocate ($im, 0, 200, 0);
+$colors['tested_packages_count'] = ImageColorAllocate ($im, 100, 255, 0);
+$colors['broken_tasks_count'] = ImageColorAllocate ($im, 255, 0, 0);
+$colors['dependency_loops_count'] = ImageColorAllocate ($im, 128, 128, 0);
+$colors['dependency_looped_tasks_count'] = ImageColorAllocate ($im, 255, 128, 128);
+$colors['locked_tasks_count'] = ImageColorAllocate ($im, 128, 128, 128);
+$colors['blocked_tasks_count'] = ImageColorAllocate ($im, 128, 0, 0);
+$colors['next_tasks_count'] = ImageColorAllocate ($im, 0, 255, 255);
function scale($x, $x_min, $x_max, $scale, $log) {
if ($log) {