summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics_reporting/inc/queries.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/statistics_reporting/inc/queries.inc.php')
-rw-r--r--modules-available/statistics_reporting/inc/queries.inc.php35
1 files changed, 31 insertions, 4 deletions
diff --git a/modules-available/statistics_reporting/inc/queries.inc.php b/modules-available/statistics_reporting/inc/queries.inc.php
index c77f0ed8..f389cfb1 100644
--- a/modules-available/statistics_reporting/inc/queries.inc.php
+++ b/modules-available/statistics_reporting/inc/queries.inc.php
@@ -345,12 +345,12 @@ class Queries
return $res;
}
- public static function getDozmodStats($from, $to)
+ public static function getDozmodStats(int $from, int $to)
{
- if (!Module::isAvailable('dozmod'))
- return array('disabled' => true);
+ if (Module::get('dozmod') === false)
+ return ['disabled' => true];
- $return = array();
+ $return = [];
$return['vms'] = Database::queryFirst("SELECT Count(*) AS `total`, Sum(If(createtime >= $from, 1, 0)) AS `new`,
Sum(If(updatetime >= $from, 1, 0)) AS `updated`, Sum(If(latestversionid IS NOT NULL, 1, 0)) AS `valid`
FROM sat.imagebase
@@ -366,6 +366,33 @@ class Queries
return $return;
}
+ public static function getExamStats(int $from, int $to)
+ {
+ if (Module::get('exams') === false)
+ return ['disabled' => true];
+ $return = [];
+ $eres = Database::simpleQuery("SELECT starttime, endtime, GROUP_CONCAT(exl.locationid) AS `locs` FROM exams
+ LEFT JOIN exams_x_location exl USING (examid)
+ WHERE starttime < $to AND endtime > $from");
+ while ($row = $eres->fetch(PDO::FETCH_ASSOC)) {
+ // Get all boot events
+ $data = ['from' => $row['starttime'], 'to' => $row['endtime']];
+ if (empty($row['locs'])) {
+ $exam = Database::queryFirst("SELECT Count(*) AS `event`, Avg(s.data) AS length FROM statistic s
+ WHERE typeid = '~session-length'
+ AND dateline BETWEEN :from AND :to", $data);
+ } else {
+ $data['locs'] = explode(',', $row['locs']);
+ $exam = Database::queryFirst("SELECT Count(*) AS `event`, Avg(s.data) AS length FROM statistic s
+ INNER JOIN machine m USING (machineuuid)
+ WHERE typeid = '~session-length' AND m.locationid IN (:locs)
+ AND dateline BETWEEN :from AND :to", $data);
+ }
+ $return[] = $exam;
+ }
+ return $return;
+ }
+
public static function getAggregatedMachineStats($from)
{
$return = array();