cleanup my totalNotFiltered code. Join Monitors as well as they can be referenced by the filter

This commit is contained in:
Isaac Connor committed 2020-11-02 12:43:45 -05:00
1 parent 492e65c2fd
commit 7650e0bf51
1 file changed
+3 -6
+3 -6
View File
@@ -181,8 +181,6 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim
if ( $where )
$where = ' WHERE '.$where;
# total has to be the # of available rows. Not sure what totalNotFiltered is actually used for yet.
$data['totalNotFiltered'] = $data['total'] = dbFetchOne('SELECT count(*) AS Total FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id'. $where, 'Total', $query['values']);
$sort = $sort == 'Monitor' ? 'M.Name' : 'E.'.$sort;
$col_str = 'E.*, M.Name AS Monitor';
@@ -229,15 +227,14 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim
}
$data['rows'] = $rows;
if ( 0 ) {
# totalNotFiltered must equal total, except when either search bar has been used
$data['totalNotFiltered'] = dbFetchOne('SELECT count(*) AS Total FROM ' .$table. ' AS E'. ($filter->sql() ? ' WHERE '.$filter->sql():''), 'Total');
$data['totalNotFiltered'] = dbFetchOne(
'SELECT count(*) AS Total FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id'. ($filter->sql() ? ' WHERE '.$filter->sql():''), 'Total');
if ( $search != '' || count($advsearch) ) {
$data['total'] = dbFetchOne('SELECT count(*) AS Total FROM ' .$table. ' AS E'.$where , 'Total', $wherevalues);
$data['total'] = dbFetchOne('SELECT count(*) AS Total FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id'.$where , 'Total', $wherevalues);
} else {
$data['total'] = $data['totalNotFiltered'];
}
}
return $data;
}
?>