collect: send last 24 h of history on client connect (not same-day only)
Replace load_today_records with load_last_24h_records which computes a rolling 24 h cutoff, globs log files for both the current and previous calendar day, and filters records by timestamp — so clients always receive a full 24 h window regardless of when midnight falls. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+3
-3
@@ -57,7 +57,7 @@ from pathlib import Path
|
||||
|
||||
from server import log_config, network, we_connect
|
||||
from server.data_model import ALL_DOMAINS, collect_snapshot
|
||||
from server.storage_helpers import auto_out_path, load_store, load_today_records, save_store
|
||||
from server.storage_helpers import auto_out_path, load_last_24h_records, load_store, save_store
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -95,9 +95,9 @@ def run(args: argparse.Namespace) -> None:
|
||||
|
||||
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)
|
||||
push_store_ref["preloaded"] = load_last_24h_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"]))
|
||||
log.info("Pre-loaded %d record(s) from the last 24 h", 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