feat(reports): add BaseReport + 4 concrete report classes - #12
Merged
Conversation
- src/chesscom/reports/base.py: abstract BaseReport with collect_data(), get_report_name(), overridable build_sheet_configs(), and concrete run() - src/chesscom/reports/member_summary.py: MemberSummaryReport (replaces generate_club_member_report.py) — single sheet, Member.from_api_response - src/chesscom/reports/prospect.py: ProspectReport (replaces generate_prospect_data.py) — username-level exclusion + dedup before expensive profile/stats fetch; no raw requests calls - src/chesscom/reports/match_eligibility.py: MatchEligibilityReport (replaces match_strengthening_extract.py) — uses filter_members_by_rating service, dynamic sheet name with variant suffix - src/chesscom/reports/match_participation.py: MatchParticipationReport (replaces club_contribution_report.py) — two-sheet workbook (Member Metrics + Match Data), uses build_participation_stats service - All reports: ChessComClient for I/O, domain services for logic, ExcelReportWriter for output; no raw requests/utils calls - 41 new unit tests (MagicMock client, tmp_path files); total 255
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.
Action 10 — Report Classes
What this PR does
Introduces
src/chesscom/reports/— a layered report abstraction that replaces the business logic in all four legacy scripts.Class hierarchy
BaseReport contract
collect_data()get_report_name()build_sheet_configs(data)run()Report highlights
MemberSummaryReport — single sheet,
Member.from_api_responsefor clean domain objects,joinedtimestamp passed from club-members endpoint.ProspectReport — exclusion and deduplication at the raw-username level before fetching full profile/stats, avoiding wasted API calls for excluded members.
MatchEligibilityReport — uses
filter_members_by_ratingservice; sheet name includes variant (CHESS/CHESS960); raisesValueErrorwhenmatch_idabsent.MatchParticipationReport — two-sheet workbook (Member Metrics + Match Data); uses
build_participation_statsservice; per-match result columns injected into Match Data sheet; raisesValueErrorwhendata_analysis_yearabsent.All reports: no raw
requestscalls, noutilsdependency, no module-level env vars.Tests (41 new → 255 total)
Each report class has a dedicated test class using
MagicMockfor the client:match_id, missingyear)build_sheet_configssheet count / namingrun()integration tests usingtmp_path