PM-4620 general statistics - #126
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR (PM-4620) adds two new country-level statistics reports—"Country Member Details" and "Top Winners by Country"—to the reports API. It wires each report end-to-end through the standard pattern (SQL file → service method → controller endpoint → report directory entry) and refactors the existing first-place-by-country.sql so all three reports derive "wins" from members."memberStats"/memberStatsHistory filtered to relevant tracks, replacing the prior reviews.submission-based logic.
Changes:
- Add
country-member-details.sqlandtop-winners-by-country.sql, plusgetCountryMemberDetails/getTopWinnersByCountryservice methods that normalize, merge (by resolved country name), and rank the results. - Refactor
first-place-by-country.sqlto the shared memberStats win-aggregation logic and switch country attribution to prefercompetitionCountryCodeoverhomeCountryCode. - Register both reports in the directory and add service and SQL structural tests.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
sql/reports/statistics/general/country-member-details.sql |
New query: per-country member counts, owned-skill counts, and top-3 winners. |
sql/reports/statistics/general/top-winners-by-country.sql |
New query: per-country total wins with deterministic top-3 winners as JSONB. |
sql/reports/statistics/general/first-place-by-country.sql |
Refactored to memberStats-based win aggregation and new country-code precedence. |
src/statistics/general-statistics.service.ts |
Adds two methods that normalize/merge/rank the new report rows. |
src/statistics/statistics-general.controller.ts |
Adds two @Get endpoints for the new reports. |
src/reports/report-directory.data.ts |
Registers the two new public reports. |
src/statistics/general-statistics.service.spec.ts |
New unit tests for normalization, merging, and empty-data defaults. |
src/statistics/statistics-general.sql.spec.ts |
New structural assertions over the three SQL files. |
src/reports/report-directory.data.spec.ts |
Asserts the new reports appear in the accessible directory. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
This pull request adds two new country-level statistics reports—"Country Member Details" and "Top Winners by Country"—and implements their backend logic, SQL queries, and API endpoints. It also updates the report directory and test coverage to include these new reports. The key changes are grouped below:
New Reports and Directory Integration:
SQL Query Additions and Improvements:
country-member-details.sqlandtop-winners-by-country.sqlto compute, respectively, member/skill/top-winner breakdowns by country and the top three winners per country, using enhanced logic for accurate aggregation and normalization. [1] [2]first-place-by-country.sqlto use consistent aggregation logic with the new reports. [1] [2]Backend Logic and API Endpoints:
getCountryMemberDetailsandgetTopWinnersByCountrymethods inGeneralStatisticsServiceto normalize, aggregate, and return the new report data with country names, member counts, skill breakdowns, and top winner details. [1] [2] [3]StatisticsGeneralControllerfor accessing the new reports.Testing Enhancements:
general-statistics.service.spec.ts.These changes collectively provide richer, more detailed country-level statistics and make them accessible through both the UI and API.