mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-05 19:15:03 +00:00
Fix count (and reported total rows) with group by on alerts
This commit is contained in:
parent
0c824b8d2d
commit
0883cef68d
1 changed files with 14 additions and 7 deletions
|
|
@ -1153,7 +1153,14 @@ function alert_store:count()
|
|||
|
||||
where_clause = self:build_where_clause()
|
||||
|
||||
local q = string.format(" SELECT count(*) as count FROM `%s` WHERE %s", table_name, where_clause)
|
||||
local q
|
||||
|
||||
if isEmptyString(self._group_by) then
|
||||
q = string.format("SELECT count(*) as count FROM `%s` WHERE %s", table_name, where_clause)
|
||||
else
|
||||
q = string.format("SELECT count(*) as count FROM (SELECT 1 FROM `%s` WHERE %s GROUP BY %s) g",
|
||||
table_name, where_clause, self._group_by)
|
||||
end
|
||||
|
||||
local count_query = interface.alert_store_query(q)
|
||||
|
||||
|
|
@ -1743,12 +1750,6 @@ function alert_store:select_request(filter, select_fields, download --[[ Availab
|
|||
return alerts, total_rows, {}
|
||||
else -- Historical
|
||||
|
||||
-- Count
|
||||
local total_row = self:count()
|
||||
|
||||
-- Add limits and sort criteria only after the count has been done
|
||||
self:add_request_ranges()
|
||||
|
||||
-- Handle Custom Queries (query_preset)
|
||||
local p = _GET["query_preset"] -- Example: &query_preset=contacts
|
||||
if not isEmptyString(p) and ntop.isEnterpriseL() then
|
||||
|
|
@ -1797,6 +1798,12 @@ function alert_store:select_request(filter, select_fields, download --[[ Availab
|
|||
end
|
||||
end
|
||||
|
||||
-- Count
|
||||
local total_row = self:count()
|
||||
|
||||
-- Add limits and sort criteria only after the count has been done
|
||||
self:add_request_ranges()
|
||||
|
||||
local res, info =
|
||||
self:select_historical(filter, select_fields, download --[[ Available only with ClickHouse ]] )
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue