[Secondary Groups] Fixed grouped agents events in node

This commit is contained in:
fermin831 2018-03-27 17:53:11 +02:00
parent e3341c98ce
commit 4d78b28d17
2 changed files with 15 additions and 38 deletions

View File

@ -3307,41 +3307,14 @@ function events_get_events_grouped_by_agent($sql_post, $offset = 0,
$fields_extra = ''; $fields_extra = '';
} }
switch ($config["dbtype"]) { if ($total) {
case "mysql": $sql = "SELECT COUNT(*) FROM (select id_agente from $table WHERE 1=1
if ($total) { $sql_post GROUP BY id_agente, event_type$groupby_extra ORDER BY id_agente ) AS t";
$sql = "SELECT COUNT(*) FROM (select id_agente from $table WHERE 1=1 }
$sql_post GROUP BY id_agente, event_type$groupby_extra ORDER BY id_agente ) AS t"; else {
} $sql = "select id_agente, count(*) as total$fields_extra from $table te LEFT JOIN tagent_secondary_group tasg
else { ON te.id_grupo = tasg.id_group
$sql = "select id_agente, count(*) as total$fields_extra from $table te LEFT JOIN tagent_secondary_group tasg WHERE id_agente > 0 $sql_post GROUP BY id_agente$groupby_extra ORDER BY id_agente LIMIT $offset,$pagination";
ON te.id_grupo = tasg.id_group
WHERE id_agente > 0 $sql_post GROUP BY id_agente$groupby_extra ORDER BY id_agente LIMIT $offset,$pagination";
}
break;
case 'postgresql':
if ($total) {
}
else {
$sql = "select id_agente, count(*) as total$fields_extra from $table
WHERE id_agente > 0 $sql_post GROUP BY id_agente$groupby_extra ORDER BY id_agente LIMIT $offset,$pagination";
}
break;
case 'oracle':
if ($total) {
}
else {
$set = array();
$set['limit'] = $pagination;
$set['offset'] = $offset;
$sql = "select id_agente, count(*) as total$fields_extra from $table
WHERE id_agente > 0 $sql_post GROUP BY id_agente, event_type$groupby_extra ORDER BY id_agente ";
$sql = oracle_recode_query ($sql, $set);
}
break;
} }
$result = array(); $result = array();
@ -3365,7 +3338,9 @@ function events_get_events_grouped_by_agent($sql_post, $offset = 0,
'event_type' => $resultado['event_type']); 'event_type' => $resultado['event_type']);
} }
else { else {
$sql = "select event_type from $table $sql = "SELECT event_type FROM $table te
LEFT JOIN tagent_secondary_group tasg
ON te.id_agente = tasg.id_agent
WHERE id_agente = ".$event['id_agente']." $sql_post ORDER BY utimestamp DESC "; WHERE id_agente = ".$event['id_agente']." $sql_post ORDER BY utimestamp DESC ";
$resultado = db_get_row_sql($sql); $resultado = db_get_row_sql($sql);

View File

@ -829,7 +829,9 @@ if (($config['dbtype'] == 'oracle') && ($result !== false)) {
if ($group_rep == 0) { if ($group_rep == 0) {
$sql = "SELECT COUNT(id_evento) $sql = "SELECT COUNT(id_evento)
FROM $event_table FROM $event_table te
LEFT JOIN tagent_secondary_group tasg
ON te.id_grupo = tasg.id_group
WHERE 1=1 $sql_post"; WHERE 1=1 $sql_post";
$total_events = (int) db_get_sql ($sql); $total_events = (int) db_get_sql ($sql);
} }