perf(illness): compute the recovery gap lazily and gate it on signal density

The illness list load triggered the cross-episode correlation fan-out on
every mount, so the page waited on up to 24 per-episode reads before it
painted. Move that work behind an explicit opt-in: the insights endpoint
takes an includeRecoveryGap query param (default off), the list reads the
count breakdown on a single fast query, and the recovery gap is computed
only when the viewer opens the Analyse expansion.

Tighten the typical-gap gate against coincidental data. A gap now counts
only from an episode that cleared a per-episode measurement floor
(MIN_GAP_MEASUREMENT_DAYS), at least MIN_EPISODES_FOR_TYPICAL_GAP such
episodes must qualify, and the median magnitude must reach
MIN_TYPICAL_GAP_MAGNITUDE_DAYS — a 0/+-1-day gap is the coincidental
baseline and is withheld as noise.
This commit is contained in:
Marc-André Bombeck committed 2026-06-20 11:58:39 +02:00
1 parent a5b3715a46
commit 1de63f2b5c
15 files changed
+313 -84

No files matched your search

+7
View File
@@ -6904,6 +6904,13 @@ paths:
type: integer
minimum: 30
maximum: 1095
- in: query
name: includeRecoveryGap
schema:
type: string
enum:
- "true"
- "false"
responses:
"200":
description: The cross-episode retrospective summary.