Swap order of query output tuple
This commit is contained in:
parent
ae00b04bbe
commit
e73f69f25e
1 changed files with 6 additions and 5 deletions
|
@ -38,18 +38,19 @@ class Power:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_list(cls, data):
|
def from_list(cls, data):
|
||||||
"""Assumes data is a list of tuples (timestamp, value, node)"""
|
"""Assumes data is a list of tuples (timestamp, node, value)"""
|
||||||
nodes = list(set([line[2] for line in data]))
|
idx_ts = 0; idx_node = 1; idx_value = 2
|
||||||
|
nodes = list(set([line[idx_node] for line in data]))
|
||||||
cls = Power(nodes)
|
cls = Power(nodes)
|
||||||
|
|
||||||
# for now ignore order to nodes
|
# for now ignore order to nodes
|
||||||
values = {}
|
values = {}
|
||||||
for l in data:
|
for l in data:
|
||||||
ts = l[0]
|
ts = l[idx_ts]
|
||||||
if ts not in values:
|
if ts not in values:
|
||||||
values[ts] = []
|
values[ts] = []
|
||||||
# node = l[1]
|
# node = l[1]
|
||||||
power = l[1]
|
power = l[idx_value]
|
||||||
values[ts].append(power)
|
values[ts].append(power)
|
||||||
|
|
||||||
epochs = sorted(values.keys())
|
epochs = sorted(values.keys())
|
||||||
|
@ -154,7 +155,7 @@ node_series as(
|
||||||
)]
|
)]
|
||||||
where n.id = any((select nodes from _job)::int[])
|
where n.id = any((select nodes from _job)::int[])
|
||||||
)
|
)
|
||||||
select a.time, a.value, ns.name from (
|
select a.time, ns.name, a.value from (
|
||||||
select
|
select
|
||||||
time_bucket(extract ('epoch' from '{interval} seconds'::interval)::int*1000, cmcavg.ts) as time,
|
time_bucket(extract ('epoch' from '{interval} seconds'::interval)::int*1000, cmcavg.ts) as time,
|
||||||
cmcavg.series_id::varchar,
|
cmcavg.series_id::varchar,
|
||||||
|
|
Loading…
Reference in a new issue