diff --git a/monitoring/db/scripts/get_detailed_power.py b/monitoring/db/scripts/get_detailed_power.py index 13e9d60..fd44c04 100755 --- a/monitoring/db/scripts/get_detailed_power.py +++ b/monitoring/db/scripts/get_detailed_power.py @@ -43,21 +43,19 @@ class Power: Returns a Power instance from a list of tuples (timestamp, node, value). Assumptions: - - data is sorted by timestamp first, then by node. Both ascending. - - for each timestamp, there is the same set of nodes. + - data is sorted by timestamp ascending + - for each timestamp, there is the same set of nodes and in the same order """ idx_ts = 0; idx_node = 1; idx_value = 2 - nodes = list(set([line[idx_node] for line in data])) + nodes = list(OrderedDict.fromkeys([line[idx_node] for line in data])) # preserves order of nodes cls = Power(nodes) - # for now ignore order to nodes values = {} for l in data: ts = l[idx_ts] if ts not in values: values[ts] = [] - # node = l[1] power = l[idx_value] values[ts].append(power)