Compare commits
5
Commits
be4de61bb7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5882585f69 | ||
|
|
2d8027cb16 | ||
|
|
fbf22284e8 | ||
|
|
6efbd50db7 | ||
|
|
3f68997b9a |
No files matched your search
@@ -46,7 +46,7 @@
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.15.1",
|
||||
"jose": "^6.2.2",
|
||||
"mongoose": "9.4.1",
|
||||
"mongoose": "9.11.4",
|
||||
"nats": "^2.29.3",
|
||||
"newrelic": "^14.3.3",
|
||||
"redis": "^5.12.1",
|
||||
|
||||
@@ -825,28 +825,65 @@ describe('CommunityStatsService', () => {
|
||||
const matchId = new mongoose.Types.ObjectId();
|
||||
const userId = new mongoose.Types.ObjectId();
|
||||
const records = Array.from({ length: 60 }, (_, index) => ({
|
||||
...record(matchId), userId: userId.toString(), gameNumber: index + 1,
|
||||
riotMatchId: `KR_${index}`, gameCreation: index * 1000,
|
||||
...record(matchId),
|
||||
userId: userId.toString(),
|
||||
gameNumber: index + 1,
|
||||
riotMatchId: `KR_${index}`,
|
||||
gameCreation: index * 1000,
|
||||
teamPosition: index < 25 ? 'MIDDLE' : 'TOP',
|
||||
}));
|
||||
const repository = {
|
||||
findUserRecordFragments: jest.fn().mockResolvedValue([{ matchId, builderVersion: MATCH_STATS_BUILDER_VERSION, records }]),
|
||||
findUserRecordFragments: jest
|
||||
.fn()
|
||||
.mockResolvedValue([
|
||||
{ matchId, builderVersion: MATCH_STATS_BUILDER_VERSION, records },
|
||||
]),
|
||||
findDetailsByMatches: jest.fn().mockResolvedValue([]),
|
||||
} as unknown as jest.Mocked<MatchStatsRepository>;
|
||||
const cache = { get: jest.fn().mockResolvedValue(null), set: jest.fn().mockResolvedValue(undefined) } as unknown as CommunityStatsCacheService;
|
||||
const service = new CommunityStatsService({} as ConnectionService, cache, repository, {} as MatchStatsService);
|
||||
(service as unknown as { resolveContext: jest.Mock }).resolveContext = jest.fn().mockResolvedValue({
|
||||
community: {}, season: { id: 'all', label: '전체', startedAt: null, endedAt: null }, from: null, to: null,
|
||||
const cache = {
|
||||
get: jest.fn().mockResolvedValue(null),
|
||||
set: jest.fn().mockResolvedValue(undefined),
|
||||
} as unknown as CommunityStatsCacheService;
|
||||
const service = new CommunityStatsService(
|
||||
{} as ConnectionService,
|
||||
cache,
|
||||
repository,
|
||||
{} as MatchStatsService,
|
||||
);
|
||||
(service as unknown as { resolveContext: jest.Mock }).resolveContext = jest
|
||||
.fn()
|
||||
.mockResolvedValue({
|
||||
community: {},
|
||||
season: { id: 'all', label: '전체', startedAt: null, endedAt: null },
|
||||
from: null,
|
||||
to: null,
|
||||
});
|
||||
const mid = await service.getUserInternalHistory({
|
||||
communityId,
|
||||
userId,
|
||||
filters: { limit: 20, lane: 'MIDDLE', includePositionCounts: true },
|
||||
});
|
||||
const mid = await service.getUserInternalHistory({ communityId, userId, filters: { limit: 20, lane: 'MIDDLE', includePositionCounts: true } });
|
||||
expect(mid.matches).toHaveLength(20);
|
||||
expect(mid.matches[0].matchId).toBe('KR_24');
|
||||
expect(mid.matches[19].matchId).toBe('KR_5');
|
||||
expect(mid.matches[0].damageShare).toBe(30);
|
||||
expect(mid.positionCounts).toEqual({ ALL: 20, TOP: 20, JUNGLE: 0, MIDDLE: 20, BOTTOM: 0, UTILITY: 0 });
|
||||
expect(repository.findUserRecordFragments).toHaveBeenCalledWith(expect.objectContaining({ limit: 0 }));
|
||||
const all = await service.getUserInternalHistory({ communityId, userId, filters: { limit: 20, includePositionCounts: true } });
|
||||
expect(all.matches.every(game => game.teamPosition === 'TOP')).toBe(true);
|
||||
expect(mid.positionCounts).toEqual({
|
||||
ALL: 20,
|
||||
TOP: 20,
|
||||
JUNGLE: 0,
|
||||
MIDDLE: 20,
|
||||
BOTTOM: 0,
|
||||
UTILITY: 0,
|
||||
});
|
||||
expect(repository.findUserRecordFragments).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ limit: 0 }),
|
||||
);
|
||||
const all = await service.getUserInternalHistory({
|
||||
communityId,
|
||||
userId,
|
||||
filters: { limit: 20, includePositionCounts: true },
|
||||
});
|
||||
expect(all.matches.every((game) => game.teamPosition === 'TOP')).toBe(true);
|
||||
expect(all.positionCounts).toEqual(mid.positionCounts);
|
||||
});
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import { readFile } from 'node:fs/promises';
|
||||
import { resolve } from 'node:path';
|
||||
import { ConnectionService, resolveMongoDbName } from '../connection.service';
|
||||
import type {
|
||||
Community,
|
||||
MatchGameResult,
|
||||
MatchParticipant,
|
||||
MatchSeriesResult,
|
||||
@@ -250,16 +251,17 @@ async function main() {
|
||||
);
|
||||
}
|
||||
|
||||
const match = await MatchModel.create(payload);
|
||||
console.log(`[temp result seed] created=${match._id.toString()}`);
|
||||
console.log(`[temp result seed] route=/match/${match._id.toString()}`);
|
||||
const matchId = new mongoose.Types.ObjectId();
|
||||
await MatchModel.create({ ...payload, _id: matchId });
|
||||
console.log(`[temp result seed] created=${matchId.toString()}`);
|
||||
console.log(`[temp result seed] route=/match/${matchId.toString()}`);
|
||||
} finally {
|
||||
await app.close();
|
||||
}
|
||||
}
|
||||
|
||||
async function resolveCommunity(
|
||||
CommunityModel: mongoose.Model<unknown>,
|
||||
CommunityModel: mongoose.Model<Community>,
|
||||
communityId?: string,
|
||||
): Promise<CommunityLean> {
|
||||
const community = communityId
|
||||
@@ -316,11 +318,11 @@ function buildMatchPayload(
|
||||
description:
|
||||
'결과 페이지 검증용으로 생성된 30명, 6팀, 15경기 완료 임시 데이터입니다.',
|
||||
mapId: 11,
|
||||
status: 'finished',
|
||||
status: 'finished' as const,
|
||||
scheduledAt: options.scheduledAt,
|
||||
maxParticipants: TOTAL_PLAYERS,
|
||||
gameCount: GAME_COUNT_PER_SERIES_GROUP,
|
||||
gameMode: 'round-robin',
|
||||
gameMode: 'round-robin' as const,
|
||||
tournamentCodeIds: [],
|
||||
teamBuiltAt: new Date(options.scheduledAt.getTime() - 30 * 60000),
|
||||
participants,
|
||||
@@ -335,10 +337,10 @@ function buildMatchPayload(
|
||||
resultPollState: {
|
||||
startedAt: new Date(options.scheduledAt.getTime() + 2 * 60 * 60 * 1000),
|
||||
lastPolledAt: now,
|
||||
lastPollOutcome: 'matched',
|
||||
lastPollOutcome: 'matched' as const,
|
||||
matchedCount: games.length,
|
||||
expandedToAllPuuids: true,
|
||||
state: 'complete',
|
||||
state: 'complete' as const,
|
||||
},
|
||||
legacyImported: true,
|
||||
legacyImportSource: {
|
||||
|
||||
@@ -540,7 +540,7 @@ export class TournamentCodeService {
|
||||
): Promise<MatchDocument[]> {
|
||||
const MatchModel = await this.connectionService.getModel('match');
|
||||
const filter: {
|
||||
status: { $in: string[] };
|
||||
status: { $in: MatchDocument['status'][] };
|
||||
communityId?: mongoose.Types.ObjectId;
|
||||
} = {
|
||||
status: { $in: ['team-built', 'in-progress'] },
|
||||
|
||||
@@ -243,7 +243,7 @@ export class CompetitionOutboxProcessor
|
||||
function leaseFilter(event: ClaimedOutboxEvent) {
|
||||
return {
|
||||
_id: event._id,
|
||||
state: 'pending',
|
||||
state: 'pending' as const,
|
||||
attemptCount: event.attemptCount,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
"engine.io@>=6.6.0 <6.6.10": "6.6.11",
|
||||
"fast-uri@3.1.0": "3.1.4",
|
||||
"form-data@4.0.5": "4.0.6",
|
||||
"handlebars@>=3.0.0 <4.7.10": "4.7.10",
|
||||
"js-yaml@4.1.1": "4.3.0",
|
||||
"js-yaml@5.2.1": "5.2.2",
|
||||
"multer@>=2.0.0 <2.5.0": "2.5.0",
|
||||
|
||||
Generated
+32
-30
@@ -14,6 +14,7 @@ overrides:
|
||||
engine.io@>=6.6.0 <6.6.10: 6.6.11
|
||||
fast-uri@3.1.0: 3.1.4
|
||||
form-data@4.0.5: 4.0.6
|
||||
handlebars@>=3.0.0 <4.7.10: 4.7.10
|
||||
js-yaml@4.1.1: 4.3.0
|
||||
js-yaml@5.2.1: 5.2.2
|
||||
multer@>=2.0.0 <2.5.0: 2.5.0
|
||||
@@ -68,8 +69,8 @@ importers:
|
||||
specifier: ^6.2.2
|
||||
version: 6.2.2
|
||||
mongoose:
|
||||
specifier: 9.4.1
|
||||
version: 9.4.1(@aws-sdk/credential-providers@3.993.0)
|
||||
specifier: 9.11.4
|
||||
version: 9.11.4(@aws-sdk/credential-providers@3.993.0)
|
||||
nats:
|
||||
specifier: ^2.29.3
|
||||
version: 2.29.3
|
||||
@@ -1362,8 +1363,8 @@ packages:
|
||||
'@microsoft/tsdoc@0.16.0':
|
||||
resolution: {integrity: sha512-xgAyonlVVS+q7Vc7qLW0UrJU7rSFcETRWsqdXZtjzRU8dF+6CkozTK4V4y1LwOX7j8r/vHphjDeMeGI4tNGeGA==}
|
||||
|
||||
'@mongodb-js/saslprep@1.4.13':
|
||||
resolution: {integrity: sha512-E3Sv4eCYAlKYUTx8S3ioQcDUscOif+8zZ5OnW1IzJ+Tt+EO+ke8mn+Y3FX6N1H79picwbdOavVOb1jPi2EOyrg==}
|
||||
'@mongodb-js/saslprep@1.6.3':
|
||||
resolution: {integrity: sha512-aHGFvT95c82CoQ7hb6qXpz8Hcc5PJb3ZtQ+P01QDBbyQday0mjcrJPeNJOHCgWe0pGX0zKmKP+1mWi/I/BCX9Q==}
|
||||
|
||||
'@napi-rs/wasm-runtime@0.2.12':
|
||||
resolution: {integrity: sha512-ZVWUcfwY4E/yPitQJl481FjFo3K22D6qF0DuFH6Y/nbnE11GY5uguDxZMGXPQ8WQ0128MXQD7TnfHyK4oWoIJQ==}
|
||||
@@ -2702,8 +2703,8 @@ packages:
|
||||
bser@2.1.1:
|
||||
resolution: {integrity: sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==}
|
||||
|
||||
bson@7.3.1:
|
||||
resolution: {integrity: sha512-h/C0qe6857pQhcSJHLfsR1uYGj98Ge3wKAD3Ed9KqH3wcVh+BM4Jq4xISD7vs9OPuT07n+q3QQVjslJ286j6ag==}
|
||||
bson@7.3.4:
|
||||
resolution: {integrity: sha512-eb33j2Ha6xgygjJ8bhI3sYaI9cLAbSaopZLRJQ5/rxk32XyBSoVVcbeHIzVGJx1SyQpyyoElkoEZgQrg+RVVoA==}
|
||||
engines: {node: '>=20.19.0'}
|
||||
|
||||
buffer-from@1.1.2:
|
||||
@@ -3440,8 +3441,8 @@ packages:
|
||||
graceful-fs@4.2.11:
|
||||
resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==}
|
||||
|
||||
handlebars@4.7.9:
|
||||
resolution: {integrity: sha512-4E71E0rpOaQuJR2A3xDZ+GM1HyWYv1clR58tC8emQNeQe3RH7MAzSbat+V0wG78LQBo6m6bzSG/L4pBuCsgnUQ==}
|
||||
handlebars@4.7.10:
|
||||
resolution: {integrity: sha512-P5VJMVM7qgBn6vjXMw8WG9uVI+ncf2pi72j4de4yz5ZULLj2RGqLYaKOYGsgyrViQ0tePOVlN1tDCCXXtFqXKg==}
|
||||
engines: {node: '>=0.4.7'}
|
||||
hasBin: true
|
||||
|
||||
@@ -3825,8 +3826,8 @@ packages:
|
||||
jsonfile@6.2.0:
|
||||
resolution: {integrity: sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==}
|
||||
|
||||
kareem@3.2.0:
|
||||
resolution: {integrity: sha512-VS8MWZz/cT+SqBCpVfNN4zoVz5VskR3N4+sTmUXme55e9avQHntpwpNq0yjnosISXqwJ3AQVjlbI4Dyzv//JtA==}
|
||||
kareem@3.4.1:
|
||||
resolution: {integrity: sha512-UlgCAFNAdk/HLSsbfkmbH8pJqpEN52Ek8RG53Ys1i3Q3gbCQruSrWpplZlgIGyDHX/LNoLW97ei3OG43s7UhUA==}
|
||||
engines: {node: '>=18.0.0'}
|
||||
|
||||
keyv@4.5.4:
|
||||
@@ -4179,15 +4180,15 @@ packages:
|
||||
resolution: {integrity: sha512-ZoS07RoFqpKYQwAk59qmrx8+jJHNHU30UjlU96QktiGn1ltvDr+vCznLX5DiUBLEpMAHatHNWV1nM/74ul66kA==}
|
||||
engines: {node: '>=20.19.0'}
|
||||
|
||||
mongodb@7.1.1:
|
||||
resolution: {integrity: sha512-067DXiMjcpYQl6bGjWQoTUEE9UoRViTtKFcoqX7z08I+iDZv/emH1g8XEFiO3qiDfXAheT5ozl1VffDTKhIW/w==}
|
||||
mongodb@7.7.0:
|
||||
resolution: {integrity: sha512-XG1xXEqyouAV8GCb3PuRaujofeXKpAJAPvXYWZgHl6Dz4QHSJ1nRLl0+GpqaLTwKvC0RFE9truOur34RNFY1nw==}
|
||||
engines: {node: '>=20.19.0'}
|
||||
peerDependencies:
|
||||
'@aws-sdk/credential-providers': ^3.806.0
|
||||
'@mongodb-js/zstd': ^7.0.0
|
||||
gcp-metadata: ^7.0.1
|
||||
kerberos: ^7.0.0
|
||||
mongodb-client-encryption: '>=7.0.0 <7.1.0'
|
||||
mongodb-client-encryption: ^7.2.0
|
||||
snappy: ^7.3.2
|
||||
socks: ^2.8.6
|
||||
peerDependenciesMeta:
|
||||
@@ -4206,16 +4207,16 @@ packages:
|
||||
socks:
|
||||
optional: true
|
||||
|
||||
mongoose@9.4.1:
|
||||
resolution: {integrity: sha512-4rFBWa+/wdBQSfvnOPJBpiSG6UCEbhSQh865dEdaH9Y8WfHBUC+I2XT28dp0IBIGrEwmh+gzrgZgea5PbmrHWA==}
|
||||
mongoose@9.11.4:
|
||||
resolution: {integrity: sha512-+xME0fduXl1sWF+NZpJHZaNcwQSt+X2vbJ/h7GRSZ/ltLycAkGZSEABhzic0+q3IMF66KqF0viEE5+frchKCAQ==}
|
||||
engines: {node: '>=20.19.0'}
|
||||
|
||||
mpath@0.9.0:
|
||||
resolution: {integrity: sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew==}
|
||||
engines: {node: '>=4.0.0'}
|
||||
|
||||
mquery@6.0.0:
|
||||
resolution: {integrity: sha512-b2KQNsmgtkscfeDgkYMcWGn9vZI9YoXh802VDEwE6qc50zxBFQ0Oo8ROkawbPAsXCY1/Z1yp0MagqsZStPWJjw==}
|
||||
mquery@6.0.1:
|
||||
resolution: {integrity: sha512-/Nijmq3JcpHwDM+5CwBp5yEl6fUa6jLsIhPsoQywlGXU/ZrKIvSpBzfaGnW9BLqcne/CoUwd1ch7MRqptDgFTA==}
|
||||
engines: {node: '>=20.19.0'}
|
||||
|
||||
ms@2.1.3:
|
||||
@@ -6697,7 +6698,7 @@ snapshots:
|
||||
|
||||
'@microsoft/tsdoc@0.16.0': {}
|
||||
|
||||
'@mongodb-js/saslprep@1.4.13':
|
||||
'@mongodb-js/saslprep@1.6.3':
|
||||
dependencies:
|
||||
sparse-bitfield: 3.0.3
|
||||
|
||||
@@ -8200,7 +8201,7 @@ snapshots:
|
||||
dependencies:
|
||||
node-int64: 0.4.0
|
||||
|
||||
bson@7.3.1: {}
|
||||
bson@7.3.4: {}
|
||||
|
||||
buffer-from@1.1.2: {}
|
||||
|
||||
@@ -8953,7 +8954,7 @@ snapshots:
|
||||
|
||||
graceful-fs@4.2.11: {}
|
||||
|
||||
handlebars@4.7.9:
|
||||
handlebars@4.7.10:
|
||||
dependencies:
|
||||
minimist: 1.2.8
|
||||
neo-async: 2.6.2
|
||||
@@ -9506,7 +9507,7 @@ snapshots:
|
||||
optionalDependencies:
|
||||
graceful-fs: 4.2.11
|
||||
|
||||
kareem@3.2.0: {}
|
||||
kareem@3.4.1: {}
|
||||
|
||||
keyv@4.5.4:
|
||||
dependencies:
|
||||
@@ -9792,20 +9793,21 @@ snapshots:
|
||||
'@types/whatwg-url': 13.0.0
|
||||
whatwg-url: 14.2.0
|
||||
|
||||
mongodb@7.1.1(@aws-sdk/credential-providers@3.993.0):
|
||||
mongodb@7.7.0(@aws-sdk/credential-providers@3.993.0):
|
||||
dependencies:
|
||||
'@mongodb-js/saslprep': 1.4.13
|
||||
bson: 7.3.1
|
||||
'@mongodb-js/saslprep': 1.6.3
|
||||
bson: 7.3.4
|
||||
mongodb-connection-string-url: 7.0.2
|
||||
optionalDependencies:
|
||||
'@aws-sdk/credential-providers': 3.993.0
|
||||
|
||||
mongoose@9.4.1(@aws-sdk/credential-providers@3.993.0):
|
||||
mongoose@9.11.4(@aws-sdk/credential-providers@3.993.0):
|
||||
dependencies:
|
||||
kareem: 3.2.0
|
||||
mongodb: 7.1.1(@aws-sdk/credential-providers@3.993.0)
|
||||
'@standard-schema/spec': 1.1.0
|
||||
kareem: 3.4.1
|
||||
mongodb: 7.7.0(@aws-sdk/credential-providers@3.993.0)
|
||||
mpath: 0.9.0
|
||||
mquery: 6.0.0
|
||||
mquery: 6.0.1
|
||||
ms: 2.1.3
|
||||
sift: 17.1.3
|
||||
transitivePeerDependencies:
|
||||
@@ -9819,7 +9821,7 @@ snapshots:
|
||||
|
||||
mpath@0.9.0: {}
|
||||
|
||||
mquery@6.0.0: {}
|
||||
mquery@6.0.1: {}
|
||||
|
||||
ms@2.1.3: {}
|
||||
|
||||
@@ -10654,7 +10656,7 @@ snapshots:
|
||||
dependencies:
|
||||
bs-logger: 0.2.6
|
||||
fast-json-stable-stringify: 2.1.0
|
||||
handlebars: 4.7.9
|
||||
handlebars: 4.7.10
|
||||
jest: 30.3.0(@types/node@26.1.1)(ts-node@10.9.2(@types/node@26.1.1)(typescript@5.9.3))
|
||||
json5: 2.2.3
|
||||
lodash.memoize: 4.1.2
|
||||
|
||||
Reference in new issue
Block a user