Problem
src/ertimes/stats.py is 1,173 lines and contains 21 functions spanning unrelated concerns: ranking, capacity scoring, growth analysis, visualization, mental health analysis, duplicate detection, and more. This is a classic god-module problem.
The unresolved merge conflict (see #98) is a direct symptom — large, sprawling files are harder to review, harder to merge, and harder to keep correct.
Impact
High — The module is difficult to navigate, test in isolation, and extend without risk of unintended side effects.
Proposed Refactor
Split stats.py into focused modules:
| New Module |
Responsibility |
stats_ranking.py |
Hospital/county ranking functions |
stats_analysis.py |
Capacity scoring, mismatch detection, growth |
stats_visualization.py |
All plotting/mapping functions |
stats_reports.py |
Report generation, summaries |
Keep a thin stats.py that re-exports the public API for backwards compatibility during the transition.
Acceptance Criteria
- No single module exceeds ~400 lines (rough approx. guess)
- All existing tests continue to pass
- Public imports from
ertimes are unchanged
Problem
src/ertimes/stats.pyis 1,173 lines and contains 21 functions spanning unrelated concerns: ranking, capacity scoring, growth analysis, visualization, mental health analysis, duplicate detection, and more. This is a classic god-module problem.The unresolved merge conflict (see #98) is a direct symptom — large, sprawling files are harder to review, harder to merge, and harder to keep correct.
Impact
High — The module is difficult to navigate, test in isolation, and extend without risk of unintended side effects.
Proposed Refactor
Split
stats.pyinto focused modules:stats_ranking.pystats_analysis.pystats_visualization.pystats_reports.pyKeep a thin
stats.pythat re-exports the public API for backwards compatibility during the transition.Acceptance Criteria
ertimesare unchanged