Skip to content

feat: add general compare mode#146

Merged
ccf merged 7 commits intomainfrom
feat/general-compare-mode
Mar 25, 2026
Merged

feat: add general compare mode#146
ccf merged 7 commits intomainfrom
feat/general-compare-mode

Conversation

@ccf
Copy link
Owner

@ccf ccf commented Mar 25, 2026

Summary

  • add a new compare mode page for teams, engineers, projects, and time periods
  • add a shared compare analytics endpoint and snapshot response for unified side-by-side metrics and workflow mix
  • true up the roadmap for personal impact review, website positioning, and the new general compare mode

Testing

  • PYTHONPATH=src pytest tests/test_compare.py -q
  • ruff check src/primer/common/schemas.py src/primer/server/services/compare_service.py src/primer/server/routers/analytics.py tests/test_compare.py
  • cd frontend && ./node_modules/.bin/tsc --noEmit
  • cd frontend && ./node_modules/.bin/eslint src/pages/compare.tsx src/pages/tests/compare.test.tsx src/hooks/use-api-queries.ts src/components/layout/sidebar.tsx src/App.tsx
  • cd frontend && ./node_modules/.bin/vitest run --run src/pages/tests/compare.test.tsx

Note

Medium Risk
Introduces a new analytics endpoint and aggregation service that combines multiple metric sources and enforces role-based access, which could affect correctness/performance and authorization boundaries.

Overview
Adds a new Compare experience that lets leadership users compare teams, engineers, projects, or time periods side-by-side, including headline deltas and top workflow mix.

Implements GET /api/v1/analytics/compare with new CompareResponse schemas/types and a compare_service that builds snapshots from existing overview/productivity/quality/maturity/workspace data, computes deltas, and derives top workflows from workflow profiles; access is restricted (engineers blocked; team leads limited to their team and cannot do team-vs-team).

Wires the new page into the frontend router/sidebar, adds useCompareAnalytics, and includes frontend + backend tests for the new modes and authorization behavior.

Written by Cursor Bugbot for commit 73b0e77. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the spend limit has been reached. To enable Bugbot Autofix, raise your spend limit in the Cursor dashboard.

start_date=start_date,
end_date=end_date,
),
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated snapshot-building logic across two functions

Low Severity

_build_period_snapshot and _build_team_snapshot have nearly identical bodies — both call the same four service functions (get_overview, get_productivity_metrics, get_quality_metrics, get_maturity_analytics) and construct a CompareSnapshot with the exact same field mappings. The only difference is how label is determined. If the snapshot field mappings ever need to change, both functions must be updated in lockstep, risking inconsistent bug fixes.

Additional Locations (1)
Fix in Cursor Fix in Web

@ccf ccf merged commit 01849d1 into main Mar 25, 2026
8 checks passed
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