fix: use prior active window baseline for #749
This commit is contained in:
@@ -90,13 +90,19 @@ def compute_rates(
|
||||
|
||||
latest = max(_parse_ts(r["timestamp"]) for r in rows)
|
||||
recent_cutoff = latest - timedelta(hours=horizon_hours)
|
||||
baseline_cutoff = latest - timedelta(hours=horizon_hours * 2)
|
||||
|
||||
recent = [r for r in rows if _parse_ts(r["timestamp"]) >= recent_cutoff]
|
||||
baseline = [
|
||||
r for r in rows
|
||||
if baseline_cutoff <= _parse_ts(r["timestamp"]) < recent_cutoff
|
||||
]
|
||||
|
||||
earlier = [r for r in rows if _parse_ts(r["timestamp"]) < recent_cutoff]
|
||||
if earlier:
|
||||
previous_latest = max(_parse_ts(r["timestamp"]) for r in earlier)
|
||||
previous_cutoff = previous_latest - timedelta(hours=horizon_hours)
|
||||
baseline = [
|
||||
r for r in earlier
|
||||
if _parse_ts(r["timestamp"]) >= previous_cutoff
|
||||
]
|
||||
else:
|
||||
baseline = []
|
||||
|
||||
recent_rate = len(recent) / max(horizon_hours, 1)
|
||||
baseline_rate = (
|
||||
|
||||
Reference in New Issue
Block a user