Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
fix(graph): update online stats to use query criteria
Browse files Browse the repository at this point in the history
Signed-off-by: Domingo Oropeza <[email protected]>
  • Loading branch information
DIOHz0r committed Feb 8, 2018
1 parent 6b05609 commit a4aca14
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions inc/graph.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,23 +289,34 @@ public function showAgentOnlineStats() {
INNER JOIN " . $FlyvemdmAgent . " AS f ON l.`items_id` = f.`id`
WHERE l.`itemtype`='PluginFlyvemdmAgent' AND l.`id_search_option`='8'
ORDER BY agent_id ASC, online_date ASC";
$result = $DB->query($query);
if ($result && $DB->numrows($result) > 0) {
$currentId = $currentDate = null;
while ($row = $DB->fetch_assoc($result)) {
list($date, $time) = explode(' ', $row['online_date']);
//$domain[] = $date;
//$serie[] = strtotime($time);
if ($currentId != $row['agent_id']) {
$currentId = $row['agent_id'];
$range[$currentId]['name'] = $row['agent_name'] . ' (ID:' . $currentId . ')';
$range[$currentId]['data'] = [];
}
$jsTime = strtotime($row['online_date']) * 1000;
$range[$currentId]['data'][] = "{x:$jsTime, y:$jsTime}";
$request = [
'FIELDS' => [$logTable => ['new_value'], $FlyvemdmAgent => ['id', 'name']],
'FROM' => $logTable,
'INNER JOIN' => [
$FlyvemdmAgent => [
'FKEY' => [
$FlyvemdmAgent => 'id',
$logTable => 'items_id',
],
],
],
'WHERE' => ['itemtype' => 'PluginFlyvemdmAgent', 'id_search_option' => 8],
'ORDER' => ['id ASC', 'new_value ASC'],
];
$currentId = $currentDate = null;
foreach ($DB->request($request) as $data) {
list($date, $time) = explode(' ', $data['new_value']);
//$domain[] = $date;
//$serie[] = strtotime($time);
if ($currentId != $data['id']) {
$currentId = $data['id'];
$range[$currentId]['name'] = $data['name'] . ' (ID:' . $currentId . ')';
$range[$currentId]['data'] = [];
}
//$domain = array_unique($domain);
$jsTime = strtotime($data['new_value']) * 1000;
$range[$currentId]['data'][] = "{x:$jsTime, y:$jsTime}";
}
//$domain = array_unique($domain);

$out = $this->displayLineGraph(
__('Online Agents', 'flyvemdm'),
Expand Down

0 comments on commit a4aca14

Please sign in to comment.