Denormalize profile tier fields
This commit is contained in:
1 parent
89eafb8770
commit
fafacec781
5 files changed
+76
-1
No files matched your search
@@ -670,6 +670,36 @@ describe('AnalysisPipelineService', () => {
|
||||
expect(profileSet.normalizationMethod).toBe('population-percentile');
|
||||
});
|
||||
|
||||
it('denormalizes ranked solo tier fields when storing player profiles', async () => {
|
||||
const { service, updatePlayerProfile } = createPipelineHarness({
|
||||
storedAccount: createStoredAccount({
|
||||
tiers: [
|
||||
{
|
||||
fetchedAt: new Date('2026-07-03T00:00:00.000Z'),
|
||||
leaguePoints: 987,
|
||||
losses: 10,
|
||||
queueType: 'RANKED_SOLO_5x5',
|
||||
rank: '',
|
||||
tier: 'CHALLENGER',
|
||||
wins: 20,
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
await service.processUserAnalysisJob(createJobData(), 'analysis-job-1');
|
||||
|
||||
const profileSet = asRecord(
|
||||
asRecord(updatePlayerProfile.mock.calls[0]?.[1]).$set,
|
||||
);
|
||||
expect(profileSet).toMatchObject({
|
||||
isSeed: false,
|
||||
tier: 'CHALLENGER',
|
||||
division: '',
|
||||
leaguePoints: 987,
|
||||
});
|
||||
});
|
||||
|
||||
it('skips seed pipeline processing when the seed account is missing', async () => {
|
||||
const { findOneAccount, getMatchIds, service, updatePlayerProfile } =
|
||||
createPipelineHarness({
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
import {
|
||||
FEATURE_RECOMPUTE_JOB_NAME,
|
||||
BASELINE_COMPUTATION_JOB_NAME,
|
||||
DEFAULT_SEED_COLLECTION_QUEUE_TYPE,
|
||||
MAX_ANALYSIS_MATCH_COUNT,
|
||||
normalizeFeatureRecomputeBatchSize,
|
||||
normalizeRequestedMatchCount,
|
||||
@@ -833,7 +834,7 @@ export class AnalysisPipelineService {
|
||||
const accountModel = await this.connectionService.getModel('account');
|
||||
const account = await accountModel
|
||||
.findOne({ puuid })
|
||||
.lean<Pick<Account, 'isSeed' | 'puuid'> | null>()
|
||||
.lean<Pick<Account, 'isSeed' | 'puuid' | 'tiers'> | null>()
|
||||
.exec();
|
||||
const features = await playerMatchFeatureModel
|
||||
.find({
|
||||
@@ -853,6 +854,7 @@ export class AnalysisPipelineService {
|
||||
await this.storeBuiltProfile({
|
||||
features,
|
||||
isSeed: account?.isSeed ?? false,
|
||||
tierInfo: account ? this.resolveRankedSoloTier(account) : undefined,
|
||||
puuid,
|
||||
queueId,
|
||||
});
|
||||
@@ -866,6 +868,7 @@ export class AnalysisPipelineService {
|
||||
await this.storeBuiltProfile({
|
||||
features: extractedFeatures,
|
||||
isSeed: account.isSeed,
|
||||
tierInfo: this.resolveRankedSoloTier(account),
|
||||
puuid: account.puuid,
|
||||
queueId: data.queueId,
|
||||
});
|
||||
@@ -928,12 +931,16 @@ export class AnalysisPipelineService {
|
||||
private async storeBuiltProfile(params: {
|
||||
features: PlayerMatchFeature[] | ExtractedPlayerMatchFeature[];
|
||||
isSeed: boolean;
|
||||
tierInfo?: TierInfo;
|
||||
puuid: string;
|
||||
queueId: number;
|
||||
}): Promise<void> {
|
||||
const profile = this.profileBuilderService.buildProfile({
|
||||
features: params.features,
|
||||
isSeed: params.isSeed,
|
||||
tier: params.tierInfo?.tier,
|
||||
division: params.tierInfo?.rank,
|
||||
leaguePoints: params.tierInfo?.leaguePoints,
|
||||
puuid: params.puuid,
|
||||
queueId: params.queueId,
|
||||
});
|
||||
@@ -952,6 +959,14 @@ export class AnalysisPipelineService {
|
||||
.exec();
|
||||
}
|
||||
|
||||
private resolveRankedSoloTier(
|
||||
account: Pick<Account, 'tiers'>,
|
||||
): TierInfo | undefined {
|
||||
return account.tiers.find(
|
||||
(tier) => tier.queueType === DEFAULT_SEED_COLLECTION_QUEUE_TYPE,
|
||||
);
|
||||
}
|
||||
|
||||
private async completeJob(
|
||||
jobId: string,
|
||||
jobType = USER_ANALYSIS_JOB_NAME,
|
||||
|
||||
@@ -92,4 +92,7 @@ export interface BuiltPlayerProfile {
|
||||
patches: string[];
|
||||
lastMatchAt?: Date;
|
||||
isSeed: boolean;
|
||||
tier?: string;
|
||||
division?: string;
|
||||
leaguePoints?: number;
|
||||
}
|
||||
@@ -160,6 +160,25 @@ describe('ProfileBuilderService', () => {
|
||||
expect(mixedProfile.normalizationMethod).toBe('registry-baseline');
|
||||
});
|
||||
|
||||
it('denormalizes ranked solo tier fields into built profiles', () => {
|
||||
const profile = service.buildProfile({
|
||||
features: [createFeature()],
|
||||
isSeed: true,
|
||||
puuid: 'seed-puuid',
|
||||
queueId: 420,
|
||||
tier: 'CHALLENGER',
|
||||
division: '',
|
||||
leaguePoints: 987,
|
||||
});
|
||||
|
||||
expect(profile).toMatchObject({
|
||||
isSeed: true,
|
||||
tier: 'CHALLENGER',
|
||||
division: '',
|
||||
leaguePoints: 987,
|
||||
});
|
||||
});
|
||||
|
||||
it('aggregates ratio metrics from raw numerator and denominator counts', () => {
|
||||
const metrics: MetricDefinition[] = [
|
||||
{
|
||||
|
||||
@@ -27,10 +27,13 @@ type ProfileSourceFeature = Pick<
|
||||
>;
|
||||
|
||||
export interface BuildProfileParams {
|
||||
division?: string;
|
||||
features: ProfileSourceFeature[];
|
||||
isSeed: boolean;
|
||||
leaguePoints?: number;
|
||||
puuid: string;
|
||||
queueId: number;
|
||||
tier?: string;
|
||||
}
|
||||
|
||||
const ROLE_ORDER: Role[] = ['TOP', 'JUNGLE', 'MIDDLE', 'BOTTOM', 'UTILITY'];
|
||||
@@ -202,6 +205,11 @@ export class ProfileBuilderService {
|
||||
Math.max(...params.features.map((feature) => feature.gameCreation)),
|
||||
),
|
||||
isSeed: params.isSeed,
|
||||
...(params.tier ? { tier: params.tier } : {}),
|
||||
...(params.division !== undefined ? { division: params.division } : {}),
|
||||
...(params.leaguePoints !== undefined
|
||||
? { leaguePoints: params.leaguePoints }
|
||||
: {}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user