Add metric: average number of problems per division - #101
Merged
Conversation
This adds a new API endpoint /api/division-problems/{handle} that calculates
the average number of problems solved per contest for each division (Div. 1-4).
Changes:
- Add DivisionProblemsService to analyze submissions by division
- Add CodeforcesClient.get_contest_divisions() to fetch and cache division info
- Add API endpoint with schema and route following existing patterns
- Add comprehensive tests for the new functionality
The metric extracts division information from contest names (e.g., 'Div. 1',
'Div. 2') and calculates per-contest averages to help users understand their
performance across different difficulty levels.
Contributor
Author
|
Hey @deyna256! 👋 This PR implements the metric requested in #100 - average number of problems per division. Key features:
Ready for review! Let me know if you'd like any changes. |
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.
Summary
Closes #100
This PR adds a new metric that calculates the average number of problems solved per contest for each division (Div. 1, Div. 2, Div. 3, Div. 4).
Changes
New Files
backend/domain/models/division_problems.py- Domain models for division analysisbackend/domain/services/division_problems_service.py- Service to analyze submissions by divisionbackend/api/routes/division_problems.py- API route handlerbackend/api/schemas/division_problems.py- Pydantic schemas for API responsebackend/tests/unit/division_problems_service/- Unit tests for the servicebackend/tests/unit/codeforces_client/test_extract_division.py- Tests for division extractionModified Files
backend/infrastructure/codeforces_client.py- Addedget_contest_divisions()method with division extraction from contest namesbackend/services/codeforces_data_service.py- Added method to expose contest divisionsbackend/api/deps.py- Added dependency provider for new servicebackend/api/routes/__init__.py- Registered new controllerbackend/domain/models/__init__.py- Exported new modelsbackend/domain/services/__init__.py- Exported new serviceAPI Endpoint
Response Example
{ "divisions": [ { "division": "Div. 1", "contest_count": 5, "total_problems_solved": 8, "average_problems_per_contest": 1.6 }, { "division": "Div. 2", "contest_count": 20, "total_problems_solved": 65, "average_problems_per_contest": 3.25 } ], "total_contests": 25, "total_problems_solved": 73, "last_updated": "2024-01-15T12:00:00Z" }Implementation Details
@deyna256