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
|
||||
def from_list(cls, data):
|
||||
"""Assumes data is a list of tuples (timestamp, value, node)"""
|
||||
nodes = list(set([line[2] for line in data]))
|
||||
"""Assumes data is a list of tuples (timestamp, node, value)"""
|
||||
idx_ts = 0; idx_node = 1; idx_value = 2
|
||||
nodes = list(set([line[idx_node] for line in data]))
|
||||
cls = Power(nodes)
|
||||
|
||||
# for now ignore order to nodes
|
||||
values = {}
|
||||
for l in data:
|
||||
ts = l[0]
|
||||
ts = l[idx_ts]
|
||||
if ts not in values:
|
||||
values[ts] = []
|
||||
# node = l[1]
|
||||
power = l[1]
|
||||
power = l[idx_value]
|
||||
values[ts].append(power)
|
||||
|
||||
epochs = sorted(values.keys())
|
||||
|
@ -154,7 +155,7 @@ node_series as(
|
|||
)]
|
||||
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
|
||||
time_bucket(extract ('epoch' from '{interval} seconds'::interval)::int*1000, cmcavg.ts) as time,
|
||||
cmcavg.series_id::varchar,
|
||||
|
|
Loading…
Reference in a new issue