Skip to content

PM-4800: stop engagement report from using stale country fallback#80

Closed
jmgasper wants to merge 2 commits intodevelopfrom
PM-4800-2
Closed

PM-4800: stop engagement report from using stale country fallback#80
jmgasper wants to merge 2 commits intodevelopfrom
PM-4800-2

Conversation

@jmgasper
Copy link
Copy Markdown
Collaborator

What was broken
The Engagement Data report could still show the wrong country or null for some members after the first QA follow-up. Members whose profile location resolved from home or competition country codes could still export the stale legacy country value instead.

Root cause
The previous fix expanded the SQL lookup coverage, but it still collapsed country resolution into a single SQL field that fell back to members.member.country. That legacy field can be stale and does not match how the profile UI resolves member location.

What was changed
Split engagement member enrichment into separate home-country and competition-country resolution fields plus the raw profile country codes.
Resolved the final export country in the report service with the same home-country-first precedence the profile UI uses, and removed the stale members.member.country fallback.
Expanded SQL coverage to resolve country names through both lookups.Country and identity.country so legacy alpha-2, alpha-3, and lookup-id values still map correctly.
Updated the report documentation to match the current country sources.

Any added/updated tests
Updated src/reports/topcoder/topcoder-reports.service.spec.ts to cover the profile-style country precedence for the report output.
Updated src/reports/topcoder/topcoder-reports.sql.spec.ts to lock the SQL against falling back to members.member.country.
Validated with pnpm lint, pnpm build, pnpm test -- src/reports/topcoder/topcoder-reports.service.spec.ts src/reports/topcoder/topcoder-reports.sql.spec.ts, and pnpm test.
Full pnpm test still fails on existing SFDC suites already red on develop: src/reports/sfdc/sfdc-reports.dto.spec.ts, src/reports/sfdc/sfdc-reports.module.spec.ts, src/reports/sfdc/sfdc-reports.controller.spec.ts, and src/reports/sfdc/sfdc-reports.service.spec.ts.

What was broken
The Engagement Data report could export the wrong country or null for some members because it did not follow the same location precedence as the Profile app.

Root cause
The engagement member enrichment SQL only resolved country from competition-country data and the denormalized member country field, so it ignored home-country data that the Profile app prefers.

What was changed
Updated the engagement member enrichment SQL to resolve country names through the lookups country table with homeCountryCode first, then competitionCountryCode, then the stored member country fallback.
Updated the engagement report service documentation to reflect the profile-aligned country precedence.

Any added/updated tests
Added src/reports/topcoder/topcoder-reports.sql.spec.ts to lock the Engagement Data country precedence in focused SQL regression coverage.
What was broken
The Engagement Data report could still show the wrong country or null for some members after the first QA follow-up. Members whose profile location resolved from home or competition country codes could still export the stale legacy country value instead.

Root cause
The previous fix expanded the SQL lookup coverage, but it still collapsed country resolution into a single SQL field that fell back to members.member.country. That legacy field can be stale and does not match how the profile UI resolves member location.

What was changed
Split engagement member enrichment into separate home-country and competition-country resolution fields plus the raw profile country codes.
Resolved the final export country in the report service with the same home-country-first precedence the profile UI uses, and removed the stale members.member.country fallback.
Expanded SQL coverage to resolve country names through both lookups.Country and identity.country so legacy alpha-2, alpha-3, and lookup-id values still map correctly.
Updated the report documentation to match the current country sources.

Any added/updated tests
Updated src/reports/topcoder/topcoder-reports.service.spec.ts to cover the profile-style country precedence for the report output.
Updated src/reports/topcoder/topcoder-reports.sql.spec.ts to lock the SQL against falling back to members.member.country.
@jmgasper jmgasper closed this Apr 10, 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