Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the simulator and roster apps to follow Clean Architecture principles by moving business logic from views into dedicated service layers. The refactoring improves code organization and separation of concerns, though several issues need to be addressed.
Key Changes:
- Created
SimulationService.run_simulation_flow()to orchestrate player fetching, validation, and simulation - Introduced
PlayerRankingServiceto encapsulate player sorting logic - Consolidated three separate CSV import implementations into a single
PlayerImportService - Removed redundant function-based views in favor of ViewSet actions
- Cleaned up views to focus solely on HTTP concerns
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| backend/simulator/views.py | Simplified view by delegating business logic to SimulationService; removed PlayerService import and helper function |
| backend/simulator/services/simulation.py | Added run_simulation_flow method to orchestrate the full simulation pipeline including player fetching |
| backend/roster/views.py | Removed redundant function-based views; added sort_by_woba as ViewSet action |
| backend/roster/urls.py | Removed standalone sort-by-woba URL pattern (now handled by ViewSet router) |
| backend/roster/services/player_ranking.py | Added PlayerRankingService class; removed duplicate get_all_players_with_stats function |
| backend/roster/services/player_import.py | New consolidated service replacing importer.py and load_csv.py |
| backend/roster/services/load_csv.py | Deleted obsolete CSV import implementation |
| backend/roster/services/importer.py | Deleted obsolete CSV import implementation |
| backend/roster/management/commands/import_test_data.py | Updated to use new PlayerImportService |
Comments suppressed due to low confidence (1)
backend/roster/services/player_import.py:4
- Import of 'Tuple' is not used.
from typing import Any, Dict, List, Optional, Tuple
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…com/jfishB/bench_analytics into 305-refactor-simulation-and-rosters
IlyaK27
approved these changes
Dec 3, 2025
Collaborator
IlyaK27
left a comment
There was a problem hiding this comment.
Good changes Luke! Thanks for implementing what we talked about on call.
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.
refactored backend (simulator and roster apps) to clean architecture!
refactors the simulator and roster apps to adhere to clean architecture principles. moved a large chunk of business logic out of views.py and into dedicated service layers so that views remain focused solely on http concerns.
key changes I made:
simulator app
roster app
deletions & cleanup