improve merging units
+ bug fix
This commit is contained in:
@ -141,6 +141,8 @@ class SEHistory(InfluxDBWrapper):
|
|||||||
table = result.get(final_key)
|
table = result.get(final_key)
|
||||||
if table is None:
|
if table is None:
|
||||||
result[final_key] = table = Table(tags, merge_key[0], ('_time', primary))
|
result[final_key] = table = Table(tags, merge_key[0], ('_time', primary))
|
||||||
|
else:
|
||||||
|
table.tags.update(tags) # for previously undefined units
|
||||||
by_idx[col_idx] = table
|
by_idx[col_idx] = table
|
||||||
for row in rows:
|
for row in rows:
|
||||||
by_idx[row[2]].append((row[0], row[1]))
|
by_idx[row[2]].append((row[0], row[1]))
|
||||||
@ -334,7 +336,7 @@ class SEHistory(InfluxDBWrapper):
|
|||||||
chunks = current.setdefault(devcombi, [])
|
chunks = current.setdefault(devcombi, [])
|
||||||
if chunks and time.localtime(chunks[-1][0])[:3] == time.localtime(ts)[:3]:
|
if chunks and time.localtime(chunks[-1][0])[:3] == time.localtime(ts)[:3]:
|
||||||
# merge when started at the same day
|
# merge when started at the same day
|
||||||
chunk = chunks[-1][1]
|
chunk = chunks[-1]
|
||||||
chunk[1] = ETERNITY
|
chunk[1] = ETERNITY
|
||||||
else:
|
else:
|
||||||
chunk = [ts, ETERNITY]
|
chunk = [ts, ETERNITY]
|
||||||
|
Reference in New Issue
Block a user