mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-09-26 11:29:12 +02:00
Merge branch '2611-Cache_de_vista_de_arbol_y_vista_de_grupos' into 'develop'
2611 cache de vista de arbol y vista de grupos See merge request artica/pandorafms!1733
This commit is contained in:
commit
8480deebba
@ -950,7 +950,7 @@ class Tree {
|
||||
SUM(if(%s, 1, 0)) as state_unknown,
|
||||
SUM(if(%s, 1, 0)) as state_notinit,
|
||||
SUM(if(%s, 1, 0)) as state_normal,
|
||||
SUM(if(%s, 1, 0)) as state_total
|
||||
SUM(if(%s AND tae.estado IS NOT NULL, 1, 0)) as state_total
|
||||
",
|
||||
$this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_CRITICAL_ALERT, true),
|
||||
$this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_WARNING_ALERT, true),
|
||||
@ -977,7 +977,8 @@ class Tree {
|
||||
FROM tagente ta
|
||||
$inner_or_left JOIN tagente_modulo tam
|
||||
ON ta.id_agente = tam.id_agente
|
||||
INNER JOIN tagente_estado tae
|
||||
AND tam.disabled = 0
|
||||
$inner_or_left JOIN tagente_estado tae
|
||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||
$inner
|
||||
WHERE ta.id_agente IN
|
||||
@ -992,14 +993,13 @@ class Tree {
|
||||
$group_search_filter
|
||||
$condition_inside
|
||||
)
|
||||
AND ta.disabled = 0 AND tam.disabled = 0
|
||||
AND ta.disabled = 0
|
||||
$condition
|
||||
$agent_search_filter
|
||||
$agent_status_filter
|
||||
$module_search_filter
|
||||
$module_status_filter
|
||||
GROUP BY ta.id_agente
|
||||
HAVING state_total > 0
|
||||
ORDER BY ta.alias ASC, ta.id_agente ASC
|
||||
";
|
||||
|
||||
|
@ -28,7 +28,6 @@ class TreeGroup extends Tree {
|
||||
$this->L1fieldName = "id_group";
|
||||
$this->L1extraFields = array(
|
||||
"tg.nombre AS `name`",
|
||||
$this->getDisplayHierarchy() ? 'tg.parent' : '0 as parent',
|
||||
"tg.icon",
|
||||
"tg.id_grupo AS gid"
|
||||
);
|
||||
@ -91,7 +90,7 @@ class TreeGroup extends Tree {
|
||||
protected function getProcessedGroups () {
|
||||
$processed_groups = array();
|
||||
// Index and process the groups
|
||||
$groups = $this->getGroupCounters(0);
|
||||
$groups = $this->getGroupCounters();
|
||||
|
||||
// If user have not permissions in parent, set parent node to 0 (all)
|
||||
// Avoid to do foreach for admins
|
||||
@ -136,8 +135,6 @@ class TreeGroup extends Tree {
|
||||
}
|
||||
|
||||
protected function getGroupCounters() {
|
||||
//FIXME PLEASE
|
||||
if (true) {
|
||||
$fields = $this->getFirstLevelFields();
|
||||
$inside_fields = $this->getFirstLevelFieldsInside();
|
||||
|
||||
@ -211,23 +208,8 @@ class TreeGroup extends Tree {
|
||||
ON x2.g = tg.id_grupo
|
||||
GROUP BY tg.id_grupo";
|
||||
$stats = db_get_all_rows_sql($sql);
|
||||
}
|
||||
else{
|
||||
$stats = db_get_all_rows_sql(
|
||||
'SELECT tgs.agents AS total_count, tgs.critical AS total_critical_count,
|
||||
tgs.unknown AS total_unknown_count, tgs.warning AS total_warning_count,
|
||||
`non-init` AS total_not_init_count, tgs.normal AS total_normal_count,
|
||||
tgs.alerts_fired AS total_alerts_count,
|
||||
tg.nombre AS name, tg.parent, tg.icon, tg.id_grupo AS gid
|
||||
FROM tgroup_stat tgs
|
||||
INNER JOIN tgrupo tg
|
||||
ON tg.id_grupo = tgs.id_group
|
||||
');
|
||||
}
|
||||
|
||||
# Update the group cache (from db or calculated).
|
||||
$group_stats = array();
|
||||
|
||||
foreach ($stats as $group) {
|
||||
$group_stats[$group['gid']]['total_count'] = (int)$group['total_count'];
|
||||
$group_stats[$group['gid']]['total_critical_count'] = (int)$group['total_critical_count'];
|
||||
@ -243,11 +225,13 @@ class TreeGroup extends Tree {
|
||||
$group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]);
|
||||
}
|
||||
|
||||
if (isset($group_stats[$group_id])) {
|
||||
return $group_stats[$group_id];
|
||||
return $group_stats;
|
||||
}
|
||||
|
||||
return $group_stats;
|
||||
protected function getFirstLevelFields() {
|
||||
$fields = parent::getFirstLevelFields();
|
||||
$parent = $this->getDisplayHierarchy() ? 'tg.parent' : '0 as parent';
|
||||
return "$fields, $parent";
|
||||
}
|
||||
|
||||
protected function getProcessedModules($modules_tree) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user