still trying to fix eventcounts

This commit is contained in:
Isaac Connor 2016-05-06 15:56:01 -04:00
parent 52b4e98e5a
commit 9756f59a2c
1 changed files with 4 additions and 3 deletions

View File

@ -88,7 +88,7 @@ for( $i = 0; $i < count($displayMonitors); $i += 1 ) {
$monitor['zma'] = zmaStatus( $monitor ); $monitor['zma'] = zmaStatus( $monitor );
$monitor['ZoneCount'] = dbFetchOne( 'select count(Id) as ZoneCount from Zones where MonitorId = ?', 'ZoneCount', array($monitor['Id']) ); $monitor['ZoneCount'] = dbFetchOne( 'select count(Id) as ZoneCount from Zones where MonitorId = ?', 'ZoneCount', array($monitor['Id']) );
$counts = array(); $counts = array();
for ( $j = 0; $j < count($eventCounts); $j++ ) { for ( $j = 0; $j < count($eventCounts); $j += 1 ) {
$filter = addFilterTerm( $eventCounts[$j]['filter'], count($eventCounts[$j]['filter']['terms']), array( "cnj" => "and", "attr" => "MonitorId", "op" => "=", "val" => $monitor['Id'] ) ); $filter = addFilterTerm( $eventCounts[$j]['filter'], count($eventCounts[$j]['filter']['terms']), array( "cnj" => "and", "attr" => "MonitorId", "op" => "=", "val" => $monitor['Id'] ) );
parseFilter( $filter ); parseFilter( $filter );
$counts[] = "count(if(1".$filter['sql'].",1,NULL)) as EventCount$j"; $counts[] = "count(if(1".$filter['sql'].",1,NULL)) as EventCount$j";
@ -96,8 +96,9 @@ for( $i = 0; $i < count($displayMonitors); $i += 1 ) {
} }
$sql = "select ".join($counts,", ")." from Events as E where MonitorId = ?"; $sql = "select ".join($counts,", ")." from Events as E where MonitorId = ?";
$counts = dbFetchOne( $sql, NULL, array($monitor['Id']) ); $counts = dbFetchOne( $sql, NULL, array($monitor['Id']) );
if ( $counts ) $displayMonitors[$i] = array_merge( $monitor, $counts ); if ( $counts )
for ( $j = 0; $j < count($eventCounts); $j++ ) { $displayMonitors[$i] = $monitor = array_merge( $monitor, $counts );
for ( $j = 0; $j < count($eventCounts); $j += 1 ) {
$eventCounts[$j]['total'] += $monitor['EventCount'.$j]; $eventCounts[$j]['total'] += $monitor['EventCount'.$j];
} }
$zoneCount += $monitor['ZoneCount']; $zoneCount += $monitor['ZoneCount'];