mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-03-30 20:35:40 +00:00
Replace expensive per-request distance computation (1.2s cold) with precomputed distance index built during Load() and incrementally updated on IngestNewFromDB/IngestNewObservations. - Add distHopRecord/distPathRecord types for precomputed hop distances - buildDistanceIndex() iterates all packets once during Load(), computing haversine distances and storing results in distHops/distPaths slices - computeDistancesForTx() handles per-packet distance computation, shared between full rebuild and incremental ingest - IngestNewFromDB appends distance records for new packets (no rebuild) - IngestNewObservations triggers full rebuild only if paths changed - computeAnalyticsDistance() now aggregates from precomputed records instead of re-iterating all packets with JSON parsing + haversine Cold request path: ~10-20ms (filter + sort precomputed records) vs previous: ~1.2s (iterate 30K+ packets, parse JSON, resolve hops, compute haversine for each). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>