aboutsummaryrefslogtreecommitdiff
path: root/web/stats.php
blob: f8ad59d4c0287980dfaa232dea144d0484b51d55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
include("funcs.inc.php");

bab_header("Buildroot tests statistics");

$db = new db();

$sql = "select sum(status=0) as success,sum(status=1) as failures,sum(status=2) as timeouts,count(*) as total,date(builddate) as day from results group by date(builddate) order by date(builddate) desc limit 30;";

$ret = $db->query($sql);
if ($ret == FALSE) {
  echo "Cannot retrieve statistics<br/>";
  bab_footer();
  exit;
}

echo "<p style=\"text-align: center;\">Results of the last 30 days</p>";
echo "<table style=\"width: 50%; border: 2px solid black;\">\n";
echo "<tr style=\"border-bottom: 1px solid black;\">";
echo "  <td>Date</td>\n";
echo "  <td colspan=\"2\">Success</td>\n";
echo "  <td colspan=\"2\">Failure</td>\n";
echo "  <td colspan=\"2\">Timeouts</td>\n";
echo "  <td>Total</td>\n";
echo "</tr>\n";
$successtotal = 0;
$failuretotal = 0;
$timeouttotal = 0;
$total        = 0;
while ($current = mysqli_fetch_object($ret)) {
  $successtotal += $current->success;
  $failuretotal += $current->failures;
  $timeouttotal += $current->timeouts;
  $total        += $current->total;
  $successrate = sprintf("%2.2f", $current->success / $current->total * 100);
  $failurerate = sprintf("%2.2f", $current->failures / $current->total * 100);
  $timeoutrate = sprintf("%2.2f", $current->timeouts / $current->total * 100);
  echo " <tr>\n";
  echo "  <td>$current->day</td>\n";
  echo "  <td>$current->success</td>\n";
  echo "  <td>$successrate%</td>\n";
  echo "  <td>$current->failures</td>\n";
  echo "  <td>$failurerate%</td>\n";
  echo "  <td>$current->timeouts</td>\n";
  echo "  <td>$timeoutrate%</td>\n";
  echo "  <td>$current->total</td>\n";
  echo " </tr>\n";
}

$successrate = sprintf("%2.2f", $successtotal / $total * 100);
$failurerate = sprintf("%2.2f", $failuretotal / $total * 100);
$timeoutrate = sprintf("%2.2f", $timeouttotal / $total * 100);

echo " <tr style=\"border-top: 1px solid black;\">\n";
echo "  <td>Total last 30 days</td>\n";
echo "  <td>$successtotal</td>\n";
echo "  <td>$successrate%</td>\n";
echo "  <td>$failuretotal</td>\n";
echo "  <td>$failurerate%</td>\n";
echo "  <td>$timeouttotal</td>\n";
echo "  <td>$timeoutrate%</td>\n";
echo "  <td>$total</td>\n";
echo " </tr>\n";

$sql = "select sum(status=0) as success,sum(status=1) as failures,sum(status=2) as timeouts,count(*) as total from results;";

$ret = $db->query($sql);
if ($ret == FALSE) {
  echo "Cannot retrieve statistics<br/>";
  bab_footer();
  exit;
}

$result = mysqli_fetch_object($ret);

$successrate = sprintf("%2.2f", $result->success / $result->total * 100);
$failurerate = sprintf("%2.2f", $result->failures / $result->total * 100);
$timeoutrate = sprintf("%2.2f", $result->timeouts / $result->total * 100);

echo " <tr style=\"border-top: 1px solid black;\">\n";
echo "  <td>Total in history</td>\n";
echo "  <td>$result->success</td>\n";
echo "  <td>$successrate%</td>\n";
echo "  <td>$result->failures</td>\n";
echo "  <td>$failurerate%</td>\n";
echo "  <td>$result->timeouts</td>\n";
echo "  <td>$timeoutrate%</td>\n";
echo "  <td>$result->total</td>\n";
echo " </tr>\n";

echo "</table>\n";
echo "<p></p>";

echo "<center><img src=\"graph.php\"/></center>";

bab_footer();
?>