Skip to content

Refactor/split analysis layers#95

Merged
Lioo7 merged 2 commits intomasterfrom
refactor/split-analysis-layers
Jan 21, 2026
Merged

Refactor/split analysis layers#95
Lioo7 merged 2 commits intomasterfrom
refactor/split-analysis-layers

Conversation

@Lioo7
Copy link
Copy Markdown
Collaborator

@Lioo7 Lioo7 commented Jan 21, 2026

Refactor Analysis Module: Separate Logic, Service, and Presentation Layers

Summary

This PR refactors the analysis module to strictly separate concerns, resolving circular dependencies and improving maintainability. It decomposes the monolithic html_renderers.py into distinct layers for logic, service orchestration, and presentation.

Key Changes

Architecture

  • Logic Layer (stats_calculators.py): Moved heavy data processing logic (e.g., generate_single_user_asymmetric_matrix_data) out of the view layer.
  • Service Layer (report_service.py): Moved the orchestration logic (render_detailed_user_choices) here. This layer now handles data fetching, calculation, and stitching HTML components.
  • Presentation Layer (html_renderers.py): Cleaned up to focus solely on generating HTML strings from pre-calculated data.

Fixes & Improvements

  • Fix Circular Imports: Resolved dependency cycles by ensuring a clean import hierarchy (Service -> Presentation -> Logic).
  • Fix Test Mocks: Updated test_report_service.py to patch get_translation in the correct module path following the refactor.
  • Code Cleanup: Removed unused imports and exposed necessary private renderers as public functions.

Commits

  • refactor(analysis): separate logic, service, and presentation layers
  • test(analysis): fix translation mock path in report service tests

Lioo7 added 2 commits January 21, 2026 21:13
- Move data processing logic () to .
- Move service orchestration () to .
- Clean up  to focus solely on HTML generation.
- Expose necessary private renderers as public functions to support the new architecture.
Update  to patch  in  instead of , reflecting the recent refactor where the rendering logic was moved. This resolves test failures caused by unmocked translation calls.
@Lioo7 Lioo7 merged commit 3308553 into master Jan 21, 2026
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