improve merging units

+ bug fix
This commit is contained in:
2025-05-20 15:58:47 +02:00
parent 88dbfc3169
commit 6ffcf92aaf

View File

@ -141,6 +141,8 @@ class SEHistory(InfluxDBWrapper):
table = result.get(final_key)
if table is None:
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
for row in rows:
by_idx[row[2]].append((row[0], row[1]))
@ -334,7 +336,7 @@ class SEHistory(InfluxDBWrapper):
chunks = current.setdefault(devcombi, [])
if chunks and time.localtime(chunks[-1][0])[:3] == time.localtime(ts)[:3]:
# merge when started at the same day
chunk = chunks[-1][1]
chunk = chunks[-1]
chunk[1] = ETERNITY
else:
chunk = [ts, ETERNITY]