feat(api): refresh Riot ID during background updates
This commit is contained in:
1 parent
9cd5850d43
commit
e3f39fd8b8
6 files changed
+222
-24
No files matched your search
@@ -2,11 +2,11 @@
|
||||
|
||||
## Objective
|
||||
|
||||
When a user clicks `정보 갱신` on the personal match-history page, resolve the
|
||||
account's current Riot ID through Riot Account-V1 using the stored PUUID. If the
|
||||
player changed either their game name or tag line, persist the latest values on
|
||||
the same embedded Riot account so the refreshed profile header displays the new
|
||||
Riot ID.
|
||||
Whenever an account is refreshed manually from the personal match-history page
|
||||
or automatically by the stale-account background scheduler, resolve its current
|
||||
Riot ID through Riot Account-V1 using the stored PUUID. If the player changed
|
||||
either their game name or tag line, persist the latest values on the same embedded
|
||||
Riot account so the profile displays the new Riot ID.
|
||||
|
||||
The existing refresh job remains the single user-facing operation. It continues
|
||||
to refresh matches and ranked data, and additionally refreshes identity before
|
||||
@@ -16,14 +16,19 @@ emitting its completion event.
|
||||
|
||||
- Use the stored PUUID as the stable identity key; never look up the account by
|
||||
the possibly stale game name and tag line.
|
||||
- Query Riot Account-V1 on every manually queued user-history refresh job rather
|
||||
than applying a name TTL.
|
||||
- Query Riot Account-V1 on every manually queued user-history refresh job and
|
||||
every selected stale-account background refresh rather than applying a name TTL.
|
||||
- Update `gameName` and `tagLine` together only when Riot returns a matching PUUID
|
||||
and both values are non-empty.
|
||||
- Preserve the previous Riot ID if the Account-V1 lookup fails or returns an
|
||||
incomplete or mismatched response.
|
||||
- Treat identity refresh as best effort, matching the existing ranked-data refresh
|
||||
policy: log a failure but allow successful match refresh work to complete.
|
||||
- When a caller does not already know the Riot regional route, resolve it from the
|
||||
user's community and fall back to `asia` only when the community has no route.
|
||||
- Do not increment the background failure counter or enter backoff solely because
|
||||
the identity lookup failed; background statistics enrichment retains its
|
||||
existing success and failure semantics.
|
||||
- Reuse the existing refresh completion event and profile-query invalidation; do
|
||||
not add a new endpoint, response field, socket event, or frontend state path.
|
||||
- Update only the embedded Riot account used by the personal profile. Historical
|
||||
@@ -34,12 +39,13 @@ emitting its completion event.
|
||||
- NestJS 11, TypeScript 5, Mongoose 9, and Jest under `apps/api`
|
||||
- Riot Account-V1 through the existing `RiotAccountService`
|
||||
- Redis stream jobs through the existing `RiotJobWorkerService`
|
||||
- Scheduled stale-account refresh through `BackgroundRefreshScheduler`
|
||||
- React Query profile invalidation already present in `UserHistoryPage`
|
||||
|
||||
## Commands
|
||||
|
||||
- Focused tests:
|
||||
`pnpm --filter api exec jest --runInBand riot-account-enrichment.service.spec.ts riot-job-worker.service.spec.ts`
|
||||
`pnpm --filter api exec jest --runInBand riot-account-enrichment.service.spec.ts riot-job-worker.service.spec.ts background-refresh.scheduler.spec.ts`
|
||||
- API lint: `pnpm --filter api lint`
|
||||
- API build: `pnpm --filter api build`
|
||||
- Web lint: `pnpm --filter web lint`
|
||||
@@ -57,6 +63,11 @@ emitting its completion event.
|
||||
identity, match, and ranked refresh work before completion.
|
||||
- `apps/api/src/modules/riot-job-queue/riot-job-worker.service.spec.ts` verifies
|
||||
that a personal-history refresh job requests the PUUID-based identity refresh.
|
||||
- `apps/api/src/modules/riot-background-refresh/background-refresh.scheduler.ts`
|
||||
orchestrates best-effort identity refresh for stale accounts before statistics
|
||||
enrichment.
|
||||
- `apps/api/src/modules/riot-background-refresh/background-refresh.scheduler.spec.ts`
|
||||
verifies background invocation, ordering, and failure isolation.
|
||||
- `apps/web/src/pages/UserHistoryPage.tsx` already invalidates the profile query
|
||||
when the refresh socket reports completion and is not modified in this scope.
|
||||
|
||||
@@ -77,7 +88,9 @@ refreshRiotIdentity(params: {
|
||||
`updated` means both persisted Riot ID fields now match Account-V1. `unchanged`
|
||||
means the validated response matched the stored values and no database write was
|
||||
needed. `failed` means no stored account could be resolved or the external lookup
|
||||
could not safely provide a complete identity; stored values remain unchanged.
|
||||
could not safely provide a complete identity; stored values remain unchanged. If
|
||||
`region` is omitted, the service resolves the user's community and uses its
|
||||
configured `riotRegion`, falling back to `asia` only when unavailable.
|
||||
|
||||
## Code Style
|
||||
|
||||
@@ -102,6 +115,12 @@ Prettier formatting. Do not add a generic identity abstraction or new dependency
|
||||
- Verify missing values, PUUID mismatch, and Riot lookup errors return `failed`
|
||||
without overwriting or saving the stored identity.
|
||||
- Write the worker orchestration expectation before calling the new method.
|
||||
- Verify a region-less identity refresh uses the user's configured community
|
||||
region.
|
||||
- Write background scheduler expectations before adding identity refresh to the
|
||||
stale-account loop.
|
||||
- Verify identity refresh happens before statistics enrichment and that a rejected
|
||||
identity lookup does not increment background failure counters.
|
||||
- Run focused API tests after each slice, then API lint/build and web lint/build
|
||||
to verify the existing client integration remains valid.
|
||||
|
||||
@@ -113,6 +132,7 @@ Prettier formatting. Do not add a generic identity abstraction or new dependency
|
||||
- Validate both Riot ID fields before mutating the database.
|
||||
- Preserve the current Riot ID on any unsafe or failed response.
|
||||
- Keep the existing refresh route, enqueue response, and socket event compatible.
|
||||
- Keep background identity failures independent from enrichment failure counters.
|
||||
- Run focused tests before broader lint and build verification.
|
||||
|
||||
### Ask First
|
||||
@@ -136,12 +156,16 @@ Prettier formatting. Do not add a generic identity abstraction or new dependency
|
||||
|
||||
- Clicking `정보 갱신` causes the queued worker to call Account-V1 by the stored
|
||||
PUUID.
|
||||
- Selecting a stale account for background refresh also calls Account-V1 by the
|
||||
stored PUUID before statistics enrichment.
|
||||
- A changed Riot game name or tag line is persisted on the matching embedded
|
||||
account before the completion event is broadcast.
|
||||
- The completion event triggers the existing profile-query invalidation, so the
|
||||
personal history header displays the latest `gameName#tagLine`.
|
||||
- Failed, incomplete, or mismatched Riot identity responses do not overwrite the
|
||||
existing Riot ID and do not prevent otherwise successful match refresh work.
|
||||
- Background identity lookup failures do not increment the account failure counter
|
||||
or prevent otherwise successful background enrichment.
|
||||
- Focused tests, API lint/build, and web lint/production build pass.
|
||||
|
||||
## Open Questions
|
||||
|
||||
Reference in new issue
Block a user