| 341 | |
| 342 | |
| 343 | def _suspicious_aggregate( |
| 344 | base_agg: dict[str, Any], curr_agg: dict[str, Any] |
| 345 | ) -> list[str]: |
| 346 | reasons: list[str] = [] |
| 347 | for key, label, direction in _AGGREGATE_CHECKS: |
| 348 | before = base_agg.get(key, 0) |
| 349 | after = curr_agg.get(key, 0) |
| 350 | if before == after: |
| 351 | continue |
| 352 | delta = after - before |
| 353 | if direction == "down" and delta >= 0: |
| 354 | continue |
| 355 | if direction == "up" and delta <= 0: |
| 356 | continue |
| 357 | reasons.append(f"aggregate.{key} ({label}): {before} -> {after} ({delta:+})") |
| 358 | return reasons |
| 359 | |
| 360 | |
| 361 | def _changed_page_metric_lines(old: dict[str, Any], new: dict[str, Any]) -> list[str]: |