Skip to content

Refactor bottleneck analytics service#225

Open
ccf wants to merge 1 commit intomainfrom
refactor/analytics-bottlenecks
Open

Refactor bottleneck analytics service#225
ccf wants to merge 1 commit intomainfrom
refactor/analytics-bottlenecks

Conversation

@ccf
Copy link
Copy Markdown
Owner

@ccf ccf commented May 1, 2026

Summary

  • Extract bottleneck, root-cause, recovery, and time-lost analytics into analytics_bottlenecks.py
  • Keep analytics_service.get_bottleneck_analytics as a compatibility wrapper so existing callers and cache monkeypatch tests keep working
  • Remove the bottleneck-specific constants and helper implementations from the shared analytics service

Verification

  • ruff check src/primer/server/services/analytics_service.py src/primer/server/services/analytics_bottlenecks.py
  • ruff format --check src/primer/server/services/analytics_service.py src/primer/server/services/analytics_bottlenecks.py
  • pytest --import-mode=importlib tests/test_analytics.py -q
  • ruff check .
  • ruff format --check .
  • bandit -r src/ -c pyproject.toml
  • pytest --import-mode=importlib -q
  • Pre-commit and pre-push hooks passed while committing/pushing

Note

Medium Risk
Primarily a large refactor that moves complex analytics logic and caching behavior into a new module; risk is moderate due to potential subtle behavioral differences in queries/aggregation and cache wiring despite intended parity.

Overview
Refactors bottleneck analytics by moving friction impact, root-cause clustering, recovery, and time-lost calculations out of analytics_service.py into a new analytics_bottlenecks.py module.

analytics_service.get_bottleneck_analytics is now a thin compatibility wrapper that delegates to the new implementation while still using the existing cache helpers, and the bottleneck-specific constants/helpers are removed from the shared analytics service.

Reviewed by Cursor Bugbot for commit ce181bc. Bugbot is set up for automated code reviews on this repo. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant