Eagerly pre-load today's disk records into push_store_ref at startup
Previously load_today() was only called if in-memory records were empty, which was never true once the first WeConnect poll had completed. Now disk records are loaded unconditionally at startup and merged with live in-memory records (dedup by ts) when a client connects. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+5
-4
@@ -93,10 +93,11 @@ def run(args: argparse.Namespace) -> None:
|
||||
logs_dir.mkdir(exist_ok=True)
|
||||
out = auto_out_path(logs_dir, vin)
|
||||
|
||||
load_today = (lambda: load_today_records(logs_dir, vin)) if logs_dir else None
|
||||
push_clients, push_lock, push_store_ref = network.start_push_server(
|
||||
args.host, args.port, load_today=load_today
|
||||
)
|
||||
push_clients, push_lock, push_store_ref = network.start_push_server(args.host, args.port)
|
||||
if logs_dir is not None:
|
||||
push_store_ref["preloaded"] = load_today_records(logs_dir, vin)
|
||||
if push_store_ref["preloaded"]:
|
||||
log.info("Pre-loaded %d record(s) from today's log files", len(push_store_ref["preloaded"]))
|
||||
|
||||
current_day = datetime.now(timezone.utc).date()
|
||||
store = load_store(out, vin, args.interval)
|
||||
|
||||
Reference in New Issue
Block a user