Process seed accounts through analysis pipeline

This commit is contained in:
dahyeon committed 2026-07-03 01:11:21 -07:00
1 parent 63a4aeace7
commit d18e36e962
7 files changed
+343 -11

No files matched your search

@@ -245,6 +245,7 @@ interface PipelineHarnessOptions {
accountError?: Error; accountError?: Error;
existingMatchRaw?: Record<string, unknown> | null; existingMatchRaw?: Record<string, unknown> | null;
existingTimeline?: Record<string, unknown>; existingTimeline?: Record<string, unknown>;
findOneAccountResult?: Account | null;
getMatch?: jest.Mock<Promise<Record<string, unknown>>, [string, string]>; getMatch?: jest.Mock<Promise<Record<string, unknown>>, [string, string]>;
getMatchTimeline?: jest.Mock< getMatchTimeline?: jest.Mock<
Promise<Record<string, unknown>>, Promise<Record<string, unknown>>,
@@ -266,6 +267,15 @@ function createPipelineHarness(options: PipelineHarnessOptions = {}) {
const updateAccount: UpdateOneMock = jest const updateAccount: UpdateOneMock = jest
.fn<ExecQuery<AcknowledgedUpdate>, Parameters<UpdateOneMock>>() .fn<ExecQuery<AcknowledgedUpdate>, Parameters<UpdateOneMock>>()
.mockReturnValue(execResolved({ acknowledged: true })); .mockReturnValue(execResolved({ acknowledged: true }));
const findOneAccount = jest
.fn()
.mockReturnValue(
leanExecResolved(
options.findOneAccountResult === undefined
? (options.storedAccount ?? createStoredAccount())
: options.findOneAccountResult,
),
);
const findOneRiotMatch = jest.fn().mockReturnValue( const findOneRiotMatch = jest.fn().mockReturnValue(
leanExecResolved( leanExecResolved(
options.existingMatchRaw options.existingMatchRaw
@@ -288,6 +298,7 @@ function createPipelineHarness(options: PipelineHarnessOptions = {}) {
const models = { const models = {
account: { account: {
findOne: findOneAccount,
findOneAndUpdate: findOneAndUpdateAccount, findOneAndUpdate: findOneAndUpdateAccount,
updateOne: updateAccount, updateOne: updateAccount,
}, },
@@ -327,6 +338,9 @@ function createPipelineHarness(options: PipelineHarnessOptions = {}) {
jest jest
.fn<Promise<Record<string, unknown>>, [string, string]>() .fn<Promise<Record<string, unknown>>, [string, string]>()
.mockResolvedValue(createTimelinePayload()); .mockResolvedValue(createTimelinePayload());
const getMatchIds = jest
.fn<Promise<string[]>, [string, Record<string, unknown>]>()
.mockResolvedValue(options.matchIds ?? ['KR_1']);
const riotApiClient = { const riotApiClient = {
getAccountByRiotId, getAccountByRiotId,
getSummonerByPuuid: jest.fn().mockResolvedValue({ getSummonerByPuuid: jest.fn().mockResolvedValue({
@@ -335,13 +349,15 @@ function createPipelineHarness(options: PipelineHarnessOptions = {}) {
summonerLevel: 500, summonerLevel: 500,
}), }),
getLeagueEntriesByPuuid: jest.fn().mockResolvedValue([]), getLeagueEntriesByPuuid: jest.fn().mockResolvedValue([]),
getMatchIds: jest.fn().mockResolvedValue(options.matchIds ?? ['KR_1']), getMatchIds,
getMatch, getMatch,
getMatchTimeline, getMatchTimeline,
} as unknown as RiotApiClient; } as unknown as RiotApiClient;
return { return {
findOneAccount,
findOneRiotMatch, findOneRiotMatch,
getMatchIds,
getMatch, getMatch,
getMatchTimeline, getMatchTimeline,
service: new AnalysisPipelineService( service: new AnalysisPipelineService(
@@ -523,6 +539,97 @@ describe('AnalysisPipelineService', () => {
}); });
}); });
it('processes a stored seed account through the shared match feature pipeline', async () => {
const {
findOneAccount,
getMatchIds,
service,
updateAnalysisJob,
updatePlayerMatchFeature,
updatePlayerProfile,
} = createPipelineHarness({
findOneAccountResult: createStoredAccount({
isSeed: true,
puuid: 'target-puuid',
}),
});
const result = await service.processSeedAccountPipeline(
{
puuid: 'target-puuid',
platformRoute: 'kr',
regionalRoute: 'asia',
queueId: 420,
requestedMatchCount: 30,
},
'seed-job-1',
);
expect(result).toEqual({
puuid: 'target-puuid',
fetchedMatches: 1,
extractedFeatures: 1,
profileBuilt: true,
});
expect(findOneAccount).toHaveBeenCalledWith({
puuid: 'target-puuid',
isSeed: true,
});
expect(getMatchIds).toHaveBeenCalledWith('target-puuid', {
count: 30,
queue: 420,
regionalRoute: 'asia',
});
expect(updatePlayerMatchFeature).toHaveBeenCalledTimes(1);
const playerProfileUpdate = updatePlayerProfile.mock.calls[0][1];
expect(playerProfileUpdate).toMatchObject({
$set: {
isSeed: true,
puuid: 'target-puuid',
queueId: 420,
sampleGameCount: 1,
},
});
const seedStageUpdate = updateAnalysisJob.mock.calls.find(
([, update]) =>
asRecord(asRecord(update).$set).jobType === 'seed-collection' &&
asRecord(asRecord(update).$set).stage === 'extract-features',
);
expect(seedStageUpdate).toBeDefined();
});
it('skips seed pipeline processing when the seed account is missing', async () => {
const { findOneAccount, getMatchIds, service, updatePlayerProfile } =
createPipelineHarness({
findOneAccountResult: null,
});
const result = await service.processSeedAccountPipeline(
{
puuid: 'missing-puuid',
platformRoute: 'kr',
regionalRoute: 'asia',
queueId: 420,
requestedMatchCount: 30,
},
'seed-job-1',
);
expect(result).toEqual({
puuid: 'missing-puuid',
fetchedMatches: 0,
extractedFeatures: 0,
profileBuilt: false,
});
expect(findOneAccount).toHaveBeenCalledWith({
puuid: 'missing-puuid',
isSeed: true,
});
expect(getMatchIds).not.toHaveBeenCalled();
expect(updatePlayerProfile).not.toHaveBeenCalled();
});
it('completes without building a profile when no ranked matches are returned', async () => { it('completes without building a profile when no ranked matches are returned', async () => {
const { service, updateAnalysisJob, updatePlayerProfile } = const { service, updateAnalysisJob, updatePlayerProfile } =
createPipelineHarness({ createPipelineHarness({
@@ -18,11 +18,14 @@ import {
MAX_ANALYSIS_MATCH_COUNT, MAX_ANALYSIS_MATCH_COUNT,
normalizeFeatureRecomputeBatchSize, normalizeFeatureRecomputeBatchSize,
normalizeRequestedMatchCount, normalizeRequestedMatchCount,
SEED_COLLECTION_JOB_NAME,
USER_ANALYSIS_JOB_NAME, USER_ANALYSIS_JOB_NAME,
} from './analysis.constants'; } from './analysis.constants';
import type { import type {
ExtractedPlayerMatchFeature, ExtractedPlayerMatchFeature,
FeatureRecomputeJobData, FeatureRecomputeJobData,
SeedAccountPipelineData,
SeedAccountPipelineResult,
UserAnalysisJobData, UserAnalysisJobData,
} from './analysis.types'; } from './analysis.types';
import { FeatureExtractorService } from './feature-extractor.service'; import { FeatureExtractorService } from './feature-extractor.service';
@@ -274,6 +277,106 @@ export class AnalysisPipelineService {
} }
} }
public async processSeedAccountPipeline(
data: SeedAccountPipelineData,
jobId: string,
): Promise<SeedAccountPipelineResult> {
const normalizedData = {
...data,
requestedMatchCount: normalizeRequestedMatchCount(
data.requestedMatchCount,
),
};
const account = await this.findSeedAccount(normalizedData.puuid);
if (!account) {
this.logger.warn(
`Skipping missing seed account puuid="${this.safeLogText(normalizedData.puuid)}"`,
);
return {
puuid: normalizedData.puuid,
fetchedMatches: 0,
extractedFeatures: 0,
profileBuilt: false,
};
}
await this.updateJob(
jobId,
{
puuid: account.puuid,
stage: 'fetch-match-ids',
},
SEED_COLLECTION_JOB_NAME,
);
const matchIds = await this.riotApiClient.getMatchIds(account.puuid, {
count: normalizedData.requestedMatchCount,
queue: normalizedData.queueId,
regionalRoute: normalizedData.regionalRoute,
});
await this.updateJob(
jobId,
{
stage: 'fetch-match-details',
progress: {
fetchedMatches: 0,
totalMatches: matchIds.length,
},
},
SEED_COLLECTION_JOB_NAME,
);
if (matchIds.length === 0) {
return {
puuid: account.puuid,
fetchedMatches: 0,
extractedFeatures: 0,
profileBuilt: false,
};
}
const matchRecords = await this.fetchAndStoreMatches(
matchIds,
normalizedData,
jobId,
SEED_COLLECTION_JOB_NAME,
);
await this.updateJob(
jobId,
{
stage: 'extract-features',
},
SEED_COLLECTION_JOB_NAME,
);
const extractedFeatures = await this.extractAndStoreFeatures(
matchRecords,
account.puuid,
normalizedData.queueId,
);
await this.updateJob(
jobId,
{
stage: 'build-profile',
},
SEED_COLLECTION_JOB_NAME,
);
if (extractedFeatures.length > 0) {
await this.buildAndStoreProfile(
account,
normalizedData,
extractedFeatures,
);
}
return {
puuid: account.puuid,
fetchedMatches: matchRecords.length,
extractedFeatures: extractedFeatures.length,
profileBuilt: extractedFeatures.length > 0,
};
}
private async resolveAndStoreAccount( private async resolveAndStoreAccount(
data: UserAnalysisJobData, data: UserAnalysisJobData,
): Promise<Account> { ): Promise<Account> {
@@ -328,8 +431,9 @@ export class AnalysisPipelineService {
private async fetchAndStoreMatches( private async fetchAndStoreMatches(
matchIds: string[], matchIds: string[],
data: UserAnalysisJobData, data: Pick<UserAnalysisJobData, 'queueId' | 'regionalRoute'>,
jobId: string, jobId: string,
jobType = USER_ANALYSIS_JOB_NAME,
): Promise<MatchRecord[]> { ): Promise<MatchRecord[]> {
const matchRecords: MatchRecord[] = []; const matchRecords: MatchRecord[] = [];
const riotMatchModel = await this.connectionService.getModel('riotMatch'); const riotMatchModel = await this.connectionService.getModel('riotMatch');
@@ -378,12 +482,16 @@ export class AnalysisPipelineService {
`Skipping matchId="${this.safeLogText(matchId)}" after fetch/store failure: ${this.safeLogText(errorMessage(error))}`, `Skipping matchId="${this.safeLogText(matchId)}" after fetch/store failure: ${this.safeLogText(errorMessage(error))}`,
); );
} finally { } finally {
await this.updateJob(jobId, { await this.updateJob(
progress: { jobId,
fetchedMatches: index + 1, {
totalMatches: matchIds.length, progress: {
fetchedMatches: index + 1,
totalMatches: matchIds.length,
},
}, },
}); jobType,
);
} }
} }
@@ -663,7 +771,7 @@ export class AnalysisPipelineService {
private async buildAndStoreProfile( private async buildAndStoreProfile(
account: Account, account: Account,
data: UserAnalysisJobData, data: Pick<UserAnalysisJobData, 'queueId'>,
extractedFeatures: ExtractedPlayerMatchFeature[], extractedFeatures: ExtractedPlayerMatchFeature[],
): Promise<void> { ): Promise<void> {
await this.storeBuiltProfile({ await this.storeBuiltProfile({
@@ -703,6 +811,11 @@ export class AnalysisPipelineService {
return remainingTargets.length > 0; return remainingTargets.length > 0;
} }
private async findSeedAccount(puuid: string): Promise<Account | null> {
const accountModel = await this.connectionService.getModel('account');
return accountModel.findOne({ puuid, isSeed: true }).lean<Account>().exec();
}
private featureRecomputeTargetQuery(params: { private featureRecomputeTargetQuery(params: {
puuid?: string; puuid?: string;
queueId: number; queueId: number;
@@ -28,6 +28,21 @@ export interface SeedCollectionJobData {
sourceLimits?: Partial<Record<SeedSource, number>>; sourceLimits?: Partial<Record<SeedSource, number>>;
} }
export interface SeedAccountPipelineData {
puuid: string;
platformRoute: RiotPlatformRoute;
regionalRoute: RiotRegionalRoute;
queueId: number;
requestedMatchCount: number;
}
export interface SeedAccountPipelineResult {
puuid: string;
fetchedMatches: number;
extractedFeatures: number;
profileBuilt: boolean;
}
export interface ExtractedPlayerMatchFeature { export interface ExtractedPlayerMatchFeature {
matchId: string; matchId: string;
puuid: string; puuid: string;
@@ -1,7 +1,11 @@
import type { Job } from 'bullmq'; import type { Job } from 'bullmq';
import type { ConnectionService } from '../global/database/connection.service'; import type { ConnectionService } from '../global/database/connection.service';
import type { AnalysisPipelineService } from './analysis-pipeline.service';
import type { SeedCollectionService } from './seed-collection.service'; import type { SeedCollectionService } from './seed-collection.service';
import { SEED_COLLECTION_JOB_NAME } from './analysis.constants'; import {
DEFAULT_SEED_COLLECTION_MATCH_COUNT,
SEED_COLLECTION_JOB_NAME,
} from './analysis.constants';
import type { SeedCollectionJobData } from './analysis.types'; import type { SeedCollectionJobData } from './analysis.types';
import { SeedCollectionProcessor } from './seed-collection.processor'; import { SeedCollectionProcessor } from './seed-collection.processor';
@@ -36,10 +40,23 @@ function asRecord(value: unknown): Record<string, unknown> {
describe('SeedCollectionProcessor', () => { describe('SeedCollectionProcessor', () => {
it('delegates seed collection jobs and marks them completed', async () => { it('delegates seed collection jobs and marks them completed', async () => {
const collectSeedAccounts = jest.fn().mockResolvedValue({ const collectSeedAccounts = jest.fn().mockResolvedValue({
regionalRoute: 'asia',
selectedEntries: 150, selectedEntries: 150,
storedSeedAccounts: [
{
puuid: 'seed-puuid-1',
source: 'challenger',
},
],
storedAccounts: 149, storedAccounts: 149,
skippedAccounts: 1, skippedAccounts: 1,
}); });
const processSeedAccountPipeline = jest.fn().mockResolvedValue({
puuid: 'seed-puuid-1',
fetchedMatches: 30,
extractedFeatures: 30,
profileBuilt: true,
});
const updateOne = createUpdateOneMock(); const updateOne = createUpdateOneMock();
const connectionService = { const connectionService = {
getModel: jest.fn().mockResolvedValue({ updateOne }), getModel: jest.fn().mockResolvedValue({ updateOne }),
@@ -48,6 +65,9 @@ describe('SeedCollectionProcessor', () => {
{ {
collectSeedAccounts, collectSeedAccounts,
} as unknown as SeedCollectionService, } as unknown as SeedCollectionService,
{
processSeedAccountPipeline,
} as unknown as AnalysisPipelineService,
connectionService, connectionService,
); );
@@ -67,6 +87,16 @@ describe('SeedCollectionProcessor', () => {
master: 50, master: 50,
}, },
}); });
expect(processSeedAccountPipeline).toHaveBeenCalledWith(
{
puuid: 'seed-puuid-1',
platformRoute: 'kr',
regionalRoute: 'asia',
queueId: 420,
requestedMatchCount: DEFAULT_SEED_COLLECTION_MATCH_COUNT,
},
'seed-job-1',
);
expect(updateOne).toHaveBeenCalledWith( expect(updateOne).toHaveBeenCalledWith(
{ jobId: 'seed-job-1' }, { jobId: 'seed-job-1' },
{ {
@@ -139,6 +169,7 @@ describe('SeedCollectionProcessor', () => {
'rejects malformed seed collection payloads', 'rejects malformed seed collection payloads',
async ({ data, expectedError }) => { async ({ data, expectedError }) => {
const collectSeedAccounts = jest.fn(); const collectSeedAccounts = jest.fn();
const processSeedAccountPipeline = jest.fn();
const updateOne = createUpdateOneMock(); const updateOne = createUpdateOneMock();
const connectionService = { const connectionService = {
getModel: jest.fn().mockResolvedValue({ updateOne }), getModel: jest.fn().mockResolvedValue({ updateOne }),
@@ -147,6 +178,9 @@ describe('SeedCollectionProcessor', () => {
{ {
collectSeedAccounts, collectSeedAccounts,
} as unknown as SeedCollectionService, } as unknown as SeedCollectionService,
{
processSeedAccountPipeline,
} as unknown as AnalysisPipelineService,
connectionService, connectionService,
); );
@@ -160,6 +194,7 @@ describe('SeedCollectionProcessor', () => {
} as Job<unknown>), } as Job<unknown>),
).rejects.toThrow(expectedError); ).rejects.toThrow(expectedError);
expect(collectSeedAccounts).not.toHaveBeenCalled(); expect(collectSeedAccounts).not.toHaveBeenCalled();
expect(processSeedAccountPipeline).not.toHaveBeenCalled();
expect(updateOne).not.toHaveBeenCalled(); expect(updateOne).not.toHaveBeenCalled();
}, },
); );
@@ -168,6 +203,7 @@ describe('SeedCollectionProcessor', () => {
const collectSeedAccounts = jest const collectSeedAccounts = jest
.fn() .fn()
.mockRejectedValue(new Error('Riot unavailable')); .mockRejectedValue(new Error('Riot unavailable'));
const processSeedAccountPipeline = jest.fn();
const updateOne = createUpdateOneMock(); const updateOne = createUpdateOneMock();
const connectionService = { const connectionService = {
getModel: jest.fn().mockResolvedValue({ updateOne }), getModel: jest.fn().mockResolvedValue({ updateOne }),
@@ -176,6 +212,9 @@ describe('SeedCollectionProcessor', () => {
{ {
collectSeedAccounts, collectSeedAccounts,
} as unknown as SeedCollectionService, } as unknown as SeedCollectionService,
{
processSeedAccountPipeline,
} as unknown as AnalysisPipelineService,
connectionService, connectionService,
); );
@@ -189,6 +228,7 @@ describe('SeedCollectionProcessor', () => {
} as Job<unknown>), } as Job<unknown>),
).rejects.toThrow('Riot unavailable'); ).rejects.toThrow('Riot unavailable');
expect(processSeedAccountPipeline).not.toHaveBeenCalled();
expect(updateOne).toHaveBeenCalledWith( expect(updateOne).toHaveBeenCalledWith(
{ jobId: 'seed-job-1' }, { jobId: 'seed-job-1' },
{ {
@@ -205,6 +245,9 @@ describe('SeedCollectionProcessor', () => {
{ {
collectSeedAccounts: jest.fn(), collectSeedAccounts: jest.fn(),
} as unknown as SeedCollectionService, } as unknown as SeedCollectionService,
{
processSeedAccountPipeline: jest.fn(),
} as unknown as AnalysisPipelineService,
{ {
getModel: jest.fn(), getModel: jest.fn(),
} as unknown as ConnectionService, } as unknown as ConnectionService,
@@ -3,6 +3,7 @@ import type { Job } from 'bullmq';
import { ConnectionService } from '../global/database/connection.service'; import { ConnectionService } from '../global/database/connection.service';
import { SEED_SOURCES, type SeedSource } from '../global/database/schemas'; import { SEED_SOURCES, type SeedSource } from '../global/database/schemas';
import { import {
DEFAULT_SEED_COLLECTION_MATCH_COUNT,
SEED_COLLECTION_JOB_NAME, SEED_COLLECTION_JOB_NAME,
SEED_COLLECTION_QUEUE_NAME, SEED_COLLECTION_QUEUE_NAME,
} from './analysis.constants'; } from './analysis.constants';
@@ -11,12 +12,14 @@ import {
RIOT_PLATFORM_ROUTES, RIOT_PLATFORM_ROUTES,
type RiotPlatformRoute, type RiotPlatformRoute,
} from '../riot/riot.types'; } from '../riot/riot.types';
import { AnalysisPipelineService } from './analysis-pipeline.service';
import { SeedCollectionService } from './seed-collection.service'; import { SeedCollectionService } from './seed-collection.service';
@Processor(SEED_COLLECTION_QUEUE_NAME, { concurrency: 1 }) @Processor(SEED_COLLECTION_QUEUE_NAME, { concurrency: 1 })
export class SeedCollectionProcessor extends WorkerHost { export class SeedCollectionProcessor extends WorkerHost {
constructor( constructor(
private readonly seedCollectionService: SeedCollectionService, private readonly seedCollectionService: SeedCollectionService,
private readonly analysisPipelineService: AnalysisPipelineService,
private readonly connectionService: ConnectionService, private readonly connectionService: ConnectionService,
) { ) {
super(); super();
@@ -45,6 +48,18 @@ export class SeedCollectionProcessor extends WorkerHost {
platformRoute: data.platformRoute, platformRoute: data.platformRoute,
...(data.sourceLimits ? { sourceLimits: data.sourceLimits } : {}), ...(data.sourceLimits ? { sourceLimits: data.sourceLimits } : {}),
}); });
for (const storedSeedAccount of result.storedSeedAccounts) {
await this.analysisPipelineService.processSeedAccountPipeline(
{
puuid: storedSeedAccount.puuid,
platformRoute: data.platformRoute,
regionalRoute: result.regionalRoute,
queueId: data.queueId,
requestedMatchCount: DEFAULT_SEED_COLLECTION_MATCH_COUNT,
},
job.id,
);
}
await this.updateJob(job.id, { await this.updateJob(job.id, {
status: 'completed', status: 'completed',
@@ -140,7 +140,14 @@ function createHarness(options: { existingSeedAddedAt?: Date } = {}) {
); );
const findOneAndUpdateAccount: FindOneAndUpdateAccountMock = jest const findOneAndUpdateAccount: FindOneAndUpdateAccountMock = jest
.fn<LeanAccountQuery, Parameters<FindOneAndUpdateAccountMock>>() .fn<LeanAccountQuery, Parameters<FindOneAndUpdateAccountMock>>()
.mockReturnValue(leanExecResolved(createStoredAccount())); .mockImplementation((query) => {
const puuid = asRecord(query).puuid;
return leanExecResolved(
createStoredAccount({
puuid: typeof puuid === 'string' ? puuid : 'seed-puuid',
}),
);
});
const accountModel = { const accountModel = {
findOne: findOneAccount, findOne: findOneAccount,
findOneAndUpdate: findOneAndUpdateAccount, findOneAndUpdate: findOneAndUpdateAccount,
@@ -244,6 +251,20 @@ describe('SeedCollectionService', () => {
regionalRoute: 'asia', regionalRoute: 'asia',
queueType: 'RANKED_SOLO_5x5', queueType: 'RANKED_SOLO_5x5',
storedAccounts: 3, storedAccounts: 3,
storedSeedAccounts: [
{
puuid: 'challenger-high',
source: 'challenger',
},
{
puuid: 'grandmaster-one',
source: 'grandmaster',
},
{
puuid: 'master-one',
source: 'master',
},
],
skippedAccounts: 0, skippedAccounts: 0,
sourceResults: [ sourceResults: [
{ {
@@ -370,6 +391,12 @@ describe('SeedCollectionService', () => {
expect(result).toMatchObject({ expect(result).toMatchObject({
storedAccounts: 1, storedAccounts: 1,
storedSeedAccounts: [
{
puuid: 'stored-puuid',
source: 'challenger',
},
],
skippedAccounts: 1, skippedAccounts: 1,
sourceResults: [ sourceResults: [
expect.objectContaining({ expect.objectContaining({
@@ -34,6 +34,11 @@ export interface SeedCollectionSourceResult {
duplicateAccounts: number; duplicateAccounts: number;
} }
export interface SeedCollectionStoredAccount {
puuid: string;
source: SeedSource;
}
export interface SeedCollectionResult { export interface SeedCollectionResult {
platformRoute: RiotPlatformRoute; platformRoute: RiotPlatformRoute;
regionalRoute: RiotRegionalRoute; regionalRoute: RiotRegionalRoute;
@@ -44,6 +49,7 @@ export interface SeedCollectionResult {
storedAccounts: number; storedAccounts: number;
skippedAccounts: number; skippedAccounts: number;
duplicateAccounts: number; duplicateAccounts: number;
storedSeedAccounts: SeedCollectionStoredAccount[];
} }
@Injectable() @Injectable()
@@ -63,6 +69,7 @@ export class SeedCollectionService {
const regionalRoute = toRegionalRoute(platformRoute); const regionalRoute = toRegionalRoute(platformRoute);
const queueType = options.queueType ?? DEFAULT_SEED_COLLECTION_QUEUE_TYPE; const queueType = options.queueType ?? DEFAULT_SEED_COLLECTION_QUEUE_TYPE;
const sourceResults: SeedCollectionSourceResult[] = []; const sourceResults: SeedCollectionSourceResult[] = [];
const storedSeedAccounts: SeedCollectionStoredAccount[] = [];
const seenPuuids = new Set<string>(); const seenPuuids = new Set<string>();
for (const source of SEED_SOURCES) { for (const source of SEED_SOURCES) {
@@ -96,13 +103,17 @@ export class SeedCollectionService {
seenPuuids.add(selectedEntry.puuid); seenPuuids.add(selectedEntry.puuid);
try { try {
await this.storeSeedAccount({ const storedAccount = await this.storeSeedAccount({
collectedAt, collectedAt,
platformRoute, platformRoute,
puuid: selectedEntry.puuid, puuid: selectedEntry.puuid,
regionalRoute, regionalRoute,
source, source,
}); });
storedSeedAccounts.push({
puuid: storedAccount.puuid,
source,
});
sourceResult.storedAccounts += 1; sourceResult.storedAccounts += 1;
} catch (error) { } catch (error) {
sourceResult.skippedAccounts += 1; sourceResult.skippedAccounts += 1;
@@ -131,6 +142,7 @@ export class SeedCollectionService {
sourceResults, sourceResults,
'duplicateAccounts', 'duplicateAccounts',
), ),
storedSeedAccounts,
}; };
} }