diff options
Diffstat (limited to 'ui/src/controller/aggregation/counter_aggregation_controller.ts')
-rw-r--r-- | ui/src/controller/aggregation/counter_aggregation_controller.ts | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/ui/src/controller/aggregation/counter_aggregation_controller.ts b/ui/src/controller/aggregation/counter_aggregation_controller.ts index dd7f14aad..e632f8e29 100644 --- a/ui/src/controller/aggregation/counter_aggregation_controller.ts +++ b/ui/src/controller/aggregation/counter_aggregation_controller.ts @@ -15,7 +15,7 @@ import {ColumnDef} from '../../common/aggregation_data'; import {Engine} from '../../common/engine'; import {Area, Sorting} from '../../common/state'; -import {toNs} from '../../common/time'; +import {tpDurationToSeconds} from '../../common/time'; import {globals} from '../../frontend/globals'; import {Config, COUNTER_TRACK_KIND} from '../../tracks/counter'; @@ -38,21 +38,22 @@ export class CounterAggregationController extends AggregationController { } } if (ids.length === 0) return false; + const duration = area.end - area.start; + const durationSec = tpDurationToSeconds(duration); const query = `create view ${this.kind} as select name, count(1) as count, - round(sum(weighted_value)/${ - toNs(area.endSec) - toNs(area.startSec)}, 2) as avg_value, + round(sum(weighted_value)/${duration}, 2) as avg_value, last as last_value, first as first_value, max(last) - min(first) as delta_value, - round((max(last) - min(first))/${area.endSec - area.startSec}, 2) as rate, + round((max(last) - min(first))/${durationSec}, 2) as rate, min(value) as min_value, max(value) as max_value from (select *, - (min(ts + dur, ${toNs(area.endSec)}) - max(ts,${toNs(area.startSec)})) + (min(ts + dur, ${area.end}) - max(ts,${area.start})) * value as weighted_value, first_value(value) over (partition by track_id order by ts) as first, @@ -61,8 +62,8 @@ export class CounterAggregationController extends AggregationController { range between unbounded preceding and unbounded following) as last from experimental_counter_dur where track_id in (${ids}) - and ts + dur >= ${toNs(area.startSec)} and - ts <= ${toNs(area.endSec)}) + and ts + dur >= ${area.start} and + ts <= ${area.end}) join counter_track on track_id = counter_track.id group by track_id`; |