fix: refresh riot tiers from history jobs

This commit is contained in:
dahyeon committed 2026-06-07 07:16:31 -07:00
1 parent ad84bf1f89
commit c4f19d256d
4 files changed
+233 -2

No files matched your search

@@ -52,6 +52,8 @@ export interface EnrichResult {
account: RiotAccount | null;
}
export type RefreshLeagueEntriesResult = 'updated' | 'failed';
@Injectable()
export class RiotAccountEnrichmentService {
private readonly logger = new Logger(RiotAccountEnrichmentService.name);
@@ -95,6 +97,29 @@ export class RiotAccountEnrichmentService {
return promise;
}
public async refreshLeagueEntries(params: {
userId: mongoose.Types.ObjectId;
puuid: string;
platform?: RiotPlatformRoute;
}): Promise<RefreshLeagueEntriesResult> {
const UserModel = await this.connectionService.getModel('user');
const user = await UserModel.findById(params.userId).exec();
if (!user) return 'failed';
const account = user.riotAccounts.find((a) => a.puuid === params.puuid);
if (!account) return 'failed';
const outcome = await this.fetchLeagueSafe(
params.puuid,
params.platform ?? DEFAULT_PLATFORM,
);
if (outcome.status !== 'updated' || !outcome.dto) return 'failed';
this.applyLeagueEntries(account, outcome.dto);
await user.save();
return 'updated';
}
private async doEnrichRiotAccount(params: {
userId: mongoose.Types.ObjectId;
puuid: string;