refactor(server): split code_health router into a package#724
Merged
Conversation
The code-health router had grown to ~1088 lines: 13 route handlers plus about 30 serializers, aggregation helpers, score-breakdown logic, badge rendering, and async DB loaders in one module. Split it into a code_health/ package where the shared APIRouter lives in _router.py and the routes are grouped by resource (overview, findings, files, trends, coverage, refactoring-targets, churn, badge), backed by leaf helper modules (serializers, aggregation, breakdown, loaders). Pure structural move: every symbol relocates verbatim, lazy imports stay function-local, and __init__.py imports the route modules for their decorator side-effects and re-exports the helpers that routers/files.py and the tests import, so the public path repowise.server.routers.code_health still resolves router and all helpers unchanged.
|
✅ Health: 7.6 (unchanged) 📋 At a glance 🚨 Change risk: high (riskier than 88% of this repo's commits · raw 9.7/10)
📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-07-08 09:32 UTC |
swati510
approved these changes
Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The code-health router had grown to ~1088 lines: 13 route handlers plus roughly 30 serializers, aggregation helpers, score-breakdown logic, badge rendering, and async DB loaders in one module.
This splits it into a
code_health/package where the sharedAPIRouterlives in_router.pyand the routes are grouped by resource (overview, findings, files, trends, coverage, refactoring-targets, churn, badge), backed by leaf helper modules (serializers,aggregation,breakdown,loaders).Why
Route handlers grouped by resource, with pure serialization/aggregation helpers factored into their own leaf modules, are far easier to navigate than one 1000+ line router.
Safety
Pure structural move: every symbol relocates verbatim and lazy imports stay function-local.
__init__.pyimports the route modules for their decorator side-effects and re-exports the helpers thatrouters/files.pyand the tests import, so the public pathrepowise.server.routers.code_healthstill resolvesrouterand all helpers unchanged.app.include_router(code_health.router)needs no edit.Verified: the package exposes all 13 routes and they register on the app; the server health test suites (37 tests) pass.