fix: publish collection history atomically

This commit is contained in:
xavierk
2026-09-28 01:56:32 +05:30
parent 4550dd5111
commit 437ea6be73
8 changed files with 251 additions and 76 deletions
+1 -4
View File
@@ -96,6 +96,7 @@ def derive_hours_from_interval(
"""Derive hour observations from a sample pair interval.
Returns list of hour observation dicts that were written/updated.
Caller owns the transaction.
"""
prev_ts = _parse_ts(prev_sample["ts"])
next_ts = _parse_ts(next_sample["ts"])
@@ -207,9 +208,6 @@ def _upsert_hour_observation(
"WHERE id = ?",
(new_bw, new_br, new_samples, existing[0]),
)
conn.commit()
def _add_unattributed_bytes(
conn: sqlite3.Connection,
prev_ts: datetime,
@@ -241,4 +239,3 @@ def _add_unattributed_bytes(
"unattributed_bytes_read = unattributed_bytes_read + ? WHERE day = ?",
(bw_delta, br_delta, day),
)
conn.commit()