diff --git a/backend/services/sfm_events.py b/backend/services/sfm_events.py index 3430266..b866818 100644 --- a/backend/services/sfm_events.py +++ b/backend/services/sfm_events.py @@ -548,7 +548,14 @@ def _empty_stats() -> dict: def _compute_stats(events: list[dict]) -> dict: - """Roll up summary stats from a merged event list. Cheap O(N) pass.""" + """Roll up summary stats from a merged event list. Cheap O(N) pass. + + The "Overall Peak" stat (peak_pvs) EXCLUDES events flagged as false + triggers — operators care about the highest REAL event, not the + biggest sensor glitch. false_trigger_count still includes them so + operators can see how many were filtered out. last_event uses + every event regardless (it's about activity recency, not magnitude). + """ if not events: return _empty_stats() @@ -559,19 +566,22 @@ def _compute_stats(events: list[dict]) -> dict: false_trigger_count = 0 for ev in events: - pvs = ev.get("peak_vector_sum") - if pvs is not None and (peak_pvs is None or pvs > peak_pvs): - peak_pvs = pvs - peak_pvs_at = ev.get("timestamp") - peak_pvs_serial = ev.get("serial") + is_false_trigger = bool(ev.get("false_trigger")) + if is_false_trigger: + false_trigger_count += 1 + + # Peak calculation: skip flagged false triggers. + if not is_false_trigger: + pvs = ev.get("peak_vector_sum") + if pvs is not None and (peak_pvs is None or pvs > peak_pvs): + peak_pvs = pvs + peak_pvs_at = ev.get("timestamp") + peak_pvs_serial = ev.get("serial") ts = ev.get("timestamp") if ts and (last_event is None or ts > last_event): last_event = ts - if ev.get("false_trigger"): - false_trigger_count += 1 - return { "event_count": len(events), "peak_pvs": peak_pvs, diff --git a/templates/base.html b/templates/base.html index cfdf4e0..d4b9ccf 100644 --- a/templates/base.html +++ b/templates/base.html @@ -134,6 +134,17 @@ Projects + {# Events — fleet-wide event database (SFM). Cross-project + sortable/filterable event list. Day-to-day event browsing + for a specific location or unit lives on those detail + pages; this is the firehose for cross-cutting queries. #} + + + Events + + {# Tools — operator workflow hub. Active when on /tools itself or any of the workflow pages it links into (project tidy, metadata backfill, pair devices). #} diff --git a/templates/partials/projects/vibration_summary.html b/templates/partials/projects/vibration_summary.html index fb7b1df..4197af9 100644 --- a/templates/partials/projects/vibration_summary.html +++ b/templates/partials/projects/vibration_summary.html @@ -23,7 +23,7 @@ {{ "{:,}".format(summary.total_events) }}
Blastware ACH events forwarded by series3-watcher
+Fleet-wide event database. Filter by serial, date, false-trigger, or browse the units roster.