Updated totals

This commit is contained in:
Luca 2023-01-27 17:08:00 +01:00
parent 5d9fc29f4c
commit 18d7b590f5
2 changed files with 15 additions and 5 deletions

View file

@ -535,17 +535,28 @@ function driver:query(schema, tstart, tend, tags, options)
local stats = nil
-- tprint("Step: "..fstep.." / unsampled_fstep: "..unsampled_fstep)
--tprint(unsampled_series)
if options.calculate_stats then
total_serie = makeTotalSerie(series, count)
unsamples_total_serie = makeTotalSerie(unsampled_series, unsampled_count)
-- stats = ts_common.calculateStatistics(unsamples_total_serie, unsampled_fstep, tend - tstart, schema.options.metrics_type)
-- local unsampled_total_serie = makeTotalSerie(unsampled_series, unsampled_count)
-- stats = ts_common.calculateStatistics(unsampled_total_serie, unsampled_fstep, tend - tstart, schema.options.metrics_type)
stats = stats or {}
stats.by_serie = {}
if(false) then
-- Also calculate per-serie statistics
for k, v in pairs(series) do
local s = ts_common.calculateStatistics(v.data, fstep, tend - tstart, schema.options.metrics_type)
-- Adding per timeseries min-max stats
stats.by_serie[k] = table.merge(s, ts_common.calculateMinMax(v.data))
end
end
-- Also calculate per-serie statistics
for k, v in pairs(series) do
local s = ts_common.calculateStatistics(v.data, fstep, tend - tstart, schema.options.metrics_type)
for k, v in pairs(unsampled_series) do
local s = ts_common.calculateStatistics(v.data, unsampled_fstep, tend - tstart, schema.options.metrics_type)
-- Adding per timeseries min-max stats
stats.by_serie[k] = table.merge(s, ts_common.calculateMinMax(v.data))

View file

@ -80,7 +80,6 @@ end
function ts_common.calculateStatistics(total_serie, step, notused, data_type)
local total = 0
tprint(total_serie)
for idx, val in pairs(total_serie) do
if val ~= nan then
total = total + val