Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03be85d07b | ||
|
|
d269bdd92b | ||
|
|
2bac89d3dc | ||
|
|
760da1cbea | ||
|
|
ca786fd80a | ||
|
|
ac0d2b53f0 | ||
|
|
a4215f86fb | ||
|
|
a24726d7da | ||
|
|
bb68be14fa |
No files matched your search
@@ -29,20 +29,20 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@lolympus/contracts": "workspace:*",
|
||||
"@nestjs/common": "^11.0.1",
|
||||
"@nestjs/common": "^11.1.28",
|
||||
"@nestjs/config": "^4.0.4",
|
||||
"@nestjs/core": "^11.0.1",
|
||||
"@nestjs/platform-express": "^11.0.1",
|
||||
"@nestjs/platform-socket.io": "^11.1.19",
|
||||
"@nestjs/swagger": "^11.2.7",
|
||||
"@nestjs/websockets": "^11.1.19",
|
||||
"@nestjs/core": "^11.1.28",
|
||||
"@nestjs/platform-express": "^11.1.28",
|
||||
"@nestjs/platform-socket.io": "^11.1.28",
|
||||
"@nestjs/swagger": "^11.4.6",
|
||||
"@nestjs/websockets": "^11.1.28",
|
||||
"@socket.io/redis-adapter": "^8.3.0",
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.15.1",
|
||||
"jose": "^6.2.2",
|
||||
"mongoose": "^9.4.1",
|
||||
"mongoose": "9.4.1",
|
||||
"nats": "^2.29.3",
|
||||
"newrelic": "^14.3.0",
|
||||
"newrelic": "^14.3.3",
|
||||
"redis": "^5.12.1",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rxjs": "^7.8.1",
|
||||
|
||||
@@ -2,6 +2,30 @@ import mongoose from 'mongoose';
|
||||
import { AuctionService } from './auction.service';
|
||||
|
||||
describe('AuctionService', () => {
|
||||
function requireRecord(
|
||||
value: unknown,
|
||||
label: string,
|
||||
): Record<string, unknown> {
|
||||
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
||||
throw new Error(`${label} must be an object.`);
|
||||
}
|
||||
return value as Record<string, unknown>;
|
||||
}
|
||||
|
||||
function requireArray(value: unknown, label: string): unknown[] {
|
||||
if (!Array.isArray(value)) {
|
||||
throw new Error(`${label} must be an array.`);
|
||||
}
|
||||
return value as unknown[];
|
||||
}
|
||||
|
||||
function parseJsonRecord(value: unknown, label: string) {
|
||||
if (typeof value !== 'string') {
|
||||
throw new Error(`${label} must be a JSON string.`);
|
||||
}
|
||||
return requireRecord(JSON.parse(value) as unknown, label);
|
||||
}
|
||||
|
||||
function createService(models: Record<string, unknown>) {
|
||||
const auctionHistoryModel = {
|
||||
findOne: jest.fn().mockReturnValue({
|
||||
@@ -1007,7 +1031,12 @@ describe('AuctionService', () => {
|
||||
);
|
||||
const transitionInput =
|
||||
auctionRedisCommandService.applyTransition.mock.calls[0][1];
|
||||
expect(JSON.parse(transitionInput.durabilityPayloadJson)).toMatchObject({
|
||||
expect(
|
||||
parseJsonRecord(
|
||||
transitionInput.durabilityPayloadJson,
|
||||
'durabilityPayloadJson',
|
||||
),
|
||||
).toMatchObject({
|
||||
afterAuctionMongoProjection: expect.objectContaining({
|
||||
phase: 'bidding',
|
||||
revision: 2,
|
||||
@@ -1178,17 +1207,40 @@ describe('AuctionService', () => {
|
||||
|
||||
const transitionInput =
|
||||
auctionRedisCommandService.applyTransition.mock.calls[0][1];
|
||||
const durabilityPayload = JSON.parse(transitionInput.durabilityPayloadJson);
|
||||
expect(durabilityPayload.snapshotBefore).toMatchObject({
|
||||
const durabilityPayload = parseJsonRecord(
|
||||
transitionInput.durabilityPayloadJson,
|
||||
'durabilityPayloadJson',
|
||||
);
|
||||
const snapshotBefore = requireRecord(
|
||||
durabilityPayload.snapshotBefore,
|
||||
'snapshotBefore',
|
||||
);
|
||||
const snapshotBeforeTeams = requireArray(
|
||||
snapshotBefore.auctionTeams,
|
||||
'snapshotBefore.auctionTeams',
|
||||
);
|
||||
const snapshotBeforeTeam = requireRecord(
|
||||
snapshotBeforeTeams[0],
|
||||
'snapshotBefore.auctionTeams[0]',
|
||||
);
|
||||
const afterAuctionMongoProjection = requireRecord(
|
||||
durabilityPayload.afterAuctionMongoProjection,
|
||||
'afterAuctionMongoProjection',
|
||||
);
|
||||
const projectedTeams = requireArray(
|
||||
afterAuctionMongoProjection.auctionTeams,
|
||||
'afterAuctionMongoProjection.auctionTeams',
|
||||
);
|
||||
const projectedTeam = requireRecord(
|
||||
projectedTeams[0],
|
||||
'afterAuctionMongoProjection.auctionTeams[0]',
|
||||
);
|
||||
expect(snapshotBefore).toMatchObject({
|
||||
phase: 'bidding',
|
||||
revision: 4,
|
||||
});
|
||||
expect(durabilityPayload.snapshotBefore.auctionTeams[0].members).toEqual(
|
||||
[],
|
||||
);
|
||||
expect(
|
||||
durabilityPayload.afterAuctionMongoProjection.auctionTeams[0].members,
|
||||
).toEqual([
|
||||
expect(snapshotBeforeTeam.members).toEqual([]);
|
||||
expect(projectedTeam.members).toEqual([
|
||||
expect.objectContaining({
|
||||
memberAcquisitionBidPointAmount: 120,
|
||||
userId: playerUserId.toString(),
|
||||
@@ -1396,7 +1448,12 @@ describe('AuctionService', () => {
|
||||
});
|
||||
const [, transitionInput] =
|
||||
auctionRedisCommandService.applyTransition.mock.calls.at(-1) ?? [];
|
||||
expect(JSON.parse(transitionInput.durabilityPayloadJson)).toMatchObject({
|
||||
expect(
|
||||
parseJsonRecord(
|
||||
transitionInput.durabilityPayloadJson,
|
||||
'durabilityPayloadJson',
|
||||
),
|
||||
).toMatchObject({
|
||||
afterAuctionMongoProjection: {
|
||||
matchSideEffectStatus: 'pending',
|
||||
phase: 'complete',
|
||||
@@ -2567,7 +2624,10 @@ describe('AuctionService', () => {
|
||||
durationSeconds: 30,
|
||||
mode: 'set-relative',
|
||||
});
|
||||
const durabilityPayload = JSON.parse(transitionInput.durabilityPayloadJson);
|
||||
const durabilityPayload = parseJsonRecord(
|
||||
transitionInput.durabilityPayloadJson,
|
||||
'durabilityPayloadJson',
|
||||
);
|
||||
expect(durabilityPayload).toMatchObject({
|
||||
auctionActionType: 'undo',
|
||||
historyMutation: {
|
||||
|
||||
@@ -429,8 +429,14 @@ export function applyCompetitionDomainInvariantIndexes(
|
||||
}
|
||||
}
|
||||
|
||||
export type CompetitionModelName =
|
||||
| 'competition'
|
||||
| 'competitionFact'
|
||||
| 'competitionOutbox'
|
||||
| 'tournamentCodeAssignment';
|
||||
|
||||
export const competitionModelDefinitions: Array<{
|
||||
name: string;
|
||||
name: CompetitionModelName;
|
||||
schema: mongoose.Schema;
|
||||
schemaName: string;
|
||||
}> = [
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { projectCompetition } from './competition-projector';
|
||||
import {
|
||||
CompetitionDomainError,
|
||||
type CompetitionDomainErrorCode,
|
||||
} from './domain-error';
|
||||
import { generateSeriesGraph } from './series-graph';
|
||||
|
||||
describe('projectCompetition', () => {
|
||||
@@ -323,20 +327,18 @@ describe('projectCompetition', () => {
|
||||
'team-1',
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
projectCompetition({
|
||||
competitionId,
|
||||
revision: 1,
|
||||
projectorVersion: 1,
|
||||
teams,
|
||||
format,
|
||||
seriesGraph,
|
||||
facts: [{ ...accepted, seriesId: 'series-does-not-exist' }],
|
||||
}),
|
||||
).toThrow(
|
||||
expect.objectContaining({
|
||||
code: 'GAME_SERIES_MISMATCH',
|
||||
}),
|
||||
expectCompetitionDomainError(
|
||||
() =>
|
||||
projectCompetition({
|
||||
competitionId,
|
||||
revision: 1,
|
||||
projectorVersion: 1,
|
||||
teams,
|
||||
format,
|
||||
seriesGraph,
|
||||
facts: [{ ...accepted, seriesId: 'series-does-not-exist' }],
|
||||
}),
|
||||
'GAME_SERIES_MISMATCH',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -356,20 +358,18 @@ describe('projectCompetition', () => {
|
||||
'team-1',
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
projectCompetition({
|
||||
competitionId,
|
||||
revision: 1,
|
||||
projectorVersion: 1,
|
||||
teams,
|
||||
format,
|
||||
seriesGraph,
|
||||
facts: [{ ...accepted, gameSlotId: 'slot-does-not-exist' }],
|
||||
}),
|
||||
).toThrow(
|
||||
expect.objectContaining({
|
||||
code: 'GAME_SLOT_INVALID',
|
||||
}),
|
||||
expectCompetitionDomainError(
|
||||
() =>
|
||||
projectCompetition({
|
||||
competitionId,
|
||||
revision: 1,
|
||||
projectorVersion: 1,
|
||||
teams,
|
||||
format,
|
||||
seriesGraph,
|
||||
facts: [{ ...accepted, gameSlotId: 'slot-does-not-exist' }],
|
||||
}),
|
||||
'GAME_SLOT_INVALID',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -382,36 +382,34 @@ describe('projectCompetition', () => {
|
||||
};
|
||||
const seriesGraph = generateSeriesGraph({ competitionId, teams, format });
|
||||
|
||||
expect(() =>
|
||||
projectCompetition({
|
||||
competitionId,
|
||||
revision: 1,
|
||||
projectorVersion: 1,
|
||||
teams,
|
||||
format,
|
||||
seriesGraph,
|
||||
facts: [
|
||||
{
|
||||
id: 'fact-unknown-adjudication-series',
|
||||
type: 'series-adjudicated',
|
||||
competitionId,
|
||||
revision: 1,
|
||||
ordinalWithinRevision: 1,
|
||||
commandId: 'command-unknown-adjudication-series',
|
||||
schemaVersion: 1,
|
||||
actor: { type: 'user' },
|
||||
occurredAt: new Date('2026-07-12T00:00:01.000Z'),
|
||||
recordedAt: new Date('2026-07-12T00:00:02.000Z'),
|
||||
seriesId: 'series-does-not-exist',
|
||||
decision: { type: 'administrative', winnerTeamId: 'team-1' },
|
||||
reason: 'Manual correction',
|
||||
},
|
||||
],
|
||||
}),
|
||||
).toThrow(
|
||||
expect.objectContaining({
|
||||
code: 'ADJUDICATION_INVALID',
|
||||
}),
|
||||
expectCompetitionDomainError(
|
||||
() =>
|
||||
projectCompetition({
|
||||
competitionId,
|
||||
revision: 1,
|
||||
projectorVersion: 1,
|
||||
teams,
|
||||
format,
|
||||
seriesGraph,
|
||||
facts: [
|
||||
{
|
||||
id: 'fact-unknown-adjudication-series',
|
||||
type: 'series-adjudicated',
|
||||
competitionId,
|
||||
revision: 1,
|
||||
ordinalWithinRevision: 1,
|
||||
commandId: 'command-unknown-adjudication-series',
|
||||
schemaVersion: 1,
|
||||
actor: { type: 'user' },
|
||||
occurredAt: new Date('2026-07-12T00:00:01.000Z'),
|
||||
recordedAt: new Date('2026-07-12T00:00:02.000Z'),
|
||||
seriesId: 'series-does-not-exist',
|
||||
decision: { type: 'administrative', winnerTeamId: 'team-1' },
|
||||
reason: 'Manual correction',
|
||||
},
|
||||
],
|
||||
}),
|
||||
'ADJUDICATION_INVALID',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -617,3 +615,23 @@ interface GameSlotLike {
|
||||
id: string;
|
||||
ordinal: number;
|
||||
}
|
||||
|
||||
function expectCompetitionDomainError(
|
||||
action: () => unknown,
|
||||
expectedCode: CompetitionDomainErrorCode,
|
||||
): void {
|
||||
let thrown: unknown;
|
||||
try {
|
||||
action();
|
||||
} catch (error: unknown) {
|
||||
thrown = error;
|
||||
}
|
||||
|
||||
expect(thrown).toBeInstanceOf(CompetitionDomainError);
|
||||
if (!(thrown instanceof CompetitionDomainError)) {
|
||||
throw new Error(
|
||||
`Expected CompetitionDomainError, received ${String(thrown)}`,
|
||||
);
|
||||
}
|
||||
expect(thrown.code).toBe(expectedCode);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
assertReversalPreview,
|
||||
buildReversalFacts,
|
||||
CompetitionReversalError,
|
||||
previewSeriesReversal,
|
||||
} from './competition-reversal';
|
||||
|
||||
@@ -19,18 +20,18 @@ describe('Competition reversal planning', () => {
|
||||
];
|
||||
|
||||
it('rejects strict reversal when a descendant has result activity', () => {
|
||||
expect(() =>
|
||||
previewSeriesReversal({
|
||||
competitionId: 'competition-1',
|
||||
revision: 2,
|
||||
seriesId: 'series-parent',
|
||||
mode: 'strict',
|
||||
graph,
|
||||
facts,
|
||||
assignments,
|
||||
}),
|
||||
).toThrow(
|
||||
expect.objectContaining({ code: 'REVERSAL_DESCENDANT_ACTIVITY' }),
|
||||
expectCompetitionReversalError(
|
||||
() =>
|
||||
previewSeriesReversal({
|
||||
competitionId: 'competition-1',
|
||||
revision: 2,
|
||||
seriesId: 'series-parent',
|
||||
mode: 'strict',
|
||||
graph,
|
||||
facts,
|
||||
assignments,
|
||||
}),
|
||||
'REVERSAL_DESCENDANT_ACTIVITY',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -105,20 +106,22 @@ describe('Competition reversal planning', () => {
|
||||
assignments,
|
||||
});
|
||||
|
||||
expect(() =>
|
||||
assertReversalPreview(
|
||||
{
|
||||
competitionId: 'competition-1',
|
||||
revision: 3,
|
||||
seriesId: 'series-parent',
|
||||
mode: 'cascade',
|
||||
graph,
|
||||
facts,
|
||||
assignments,
|
||||
},
|
||||
preview.impactHash,
|
||||
),
|
||||
).toThrow(expect.objectContaining({ code: 'REVERSAL_PREVIEW_STALE' }));
|
||||
expectCompetitionReversalError(
|
||||
() =>
|
||||
assertReversalPreview(
|
||||
{
|
||||
competitionId: 'competition-1',
|
||||
revision: 3,
|
||||
seriesId: 'series-parent',
|
||||
mode: 'cascade',
|
||||
graph,
|
||||
facts,
|
||||
assignments,
|
||||
},
|
||||
preview.impactHash,
|
||||
),
|
||||
'REVERSAL_PREVIEW_STALE',
|
||||
);
|
||||
});
|
||||
|
||||
it('emits one append-only reversal fact for every active result fact', () => {
|
||||
@@ -160,6 +163,26 @@ describe('Competition reversal planning', () => {
|
||||
});
|
||||
});
|
||||
|
||||
function expectCompetitionReversalError(
|
||||
action: () => unknown,
|
||||
expectedCode: CompetitionReversalError['code'],
|
||||
): void {
|
||||
let thrown: unknown;
|
||||
try {
|
||||
action();
|
||||
} catch (error: unknown) {
|
||||
thrown = error;
|
||||
}
|
||||
|
||||
expect(thrown).toBeInstanceOf(CompetitionReversalError);
|
||||
if (!(thrown instanceof CompetitionReversalError)) {
|
||||
throw new Error(
|
||||
`Expected CompetitionReversalError, received ${String(thrown)}`,
|
||||
);
|
||||
}
|
||||
expect(thrown.code).toBe(expectedCode);
|
||||
}
|
||||
|
||||
function series(id: string, sources: Array<Record<string, unknown>>) {
|
||||
return {
|
||||
id,
|
||||
|
||||
@@ -22,6 +22,33 @@ function makeHandler(params: {
|
||||
}
|
||||
|
||||
describe('MatchListHandler', () => {
|
||||
afterEach(() => {
|
||||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
it('queries only matches scheduled at or after command processing time', async () => {
|
||||
const now = new Date('2026-07-25T07:30:00.000Z');
|
||||
jest.useFakeTimers().setSystemTime(now);
|
||||
const communityId = objectId('111111111111111111111111');
|
||||
const list = jest.fn().mockResolvedValue([]);
|
||||
const handler = makeHandler({
|
||||
matchService: { list },
|
||||
});
|
||||
|
||||
await handler.handle({
|
||||
communityId,
|
||||
senderUserId: 'kakao-user-1',
|
||||
senderNickname: '프리리',
|
||||
});
|
||||
|
||||
expect(list).toHaveBeenCalledWith({
|
||||
communityId,
|
||||
status: 'recruiting',
|
||||
scheduledFrom: now,
|
||||
limit: 10,
|
||||
});
|
||||
});
|
||||
|
||||
it('prints short codes, compact KST dates, and short links', async () => {
|
||||
const match = {
|
||||
_id: objectId('333333333333333333333333'),
|
||||
|
||||
@@ -19,9 +19,11 @@ export class MatchListHandler {
|
||||
senderUserId: string;
|
||||
senderNickname: string;
|
||||
}): Promise<DakaoSegment[]> {
|
||||
const scheduledFrom = new Date();
|
||||
const matches = await this.matchService.list({
|
||||
communityId: params.communityId,
|
||||
status: 'recruiting',
|
||||
scheduledFrom,
|
||||
limit: 10,
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,10 @@ import { Injectable, Logger, Scope, OnModuleInit } from '@nestjs/common';
|
||||
import mongoose from 'mongoose';
|
||||
import { applyMongoosePerformancePlugin } from '../observability/mongoose-performance.plugin';
|
||||
import { SecretService } from '../secret/secret.service';
|
||||
import { tournamentModelDefinitions, TournamentModelTypes } from './schema';
|
||||
import {
|
||||
tournamentModelDefinitions,
|
||||
type TournamentModelTypes,
|
||||
} from './schema';
|
||||
|
||||
export function resolveMongoDbName(nodeEnv = process.env.NODE_ENV): string {
|
||||
if (nodeEnv === 'prod') return 'lolympus';
|
||||
@@ -42,7 +45,8 @@ export class ConnectionService implements OnModuleInit {
|
||||
private connectionPromise: Promise<mongoose.Connection> | null = null;
|
||||
constructor(private readonly secretService: SecretService) {}
|
||||
|
||||
private tournamentModels: Map<string, mongoose.Model<any>> | null = null;
|
||||
private tournamentModels: Map<keyof TournamentModelTypes, unknown> | null =
|
||||
null;
|
||||
|
||||
public async getConnection(): Promise<mongoose.Connection> {
|
||||
if (
|
||||
@@ -89,14 +93,18 @@ export class ConnectionService implements OnModuleInit {
|
||||
modelKey: K,
|
||||
): Promise<mongoose.Model<TournamentModelTypes[K]>> {
|
||||
const connection = await this.getConnection();
|
||||
if (this.tournamentModels)
|
||||
return this.tournamentModels.get(modelKey) as mongoose.Model<
|
||||
TournamentModelTypes[K]
|
||||
>;
|
||||
if (this.tournamentModels) {
|
||||
return this.requireTournamentModel(this.tournamentModels, modelKey);
|
||||
}
|
||||
|
||||
const models = new Map<K, mongoose.Model<TournamentModelTypes[K]>>();
|
||||
const models = new Map<keyof TournamentModelTypes, unknown>();
|
||||
|
||||
tournamentModelDefinitions.forEach((modelDefinition) => {
|
||||
if (!(modelDefinition.schema instanceof mongoose.Schema)) {
|
||||
throw new Error(
|
||||
`Invalid Mongoose schema for model ${modelDefinition.name}.`,
|
||||
);
|
||||
}
|
||||
applyMongoosePerformancePlugin(modelDefinition.schema);
|
||||
// 이미 생성된 경우 컴파일 스킵.
|
||||
if (
|
||||
@@ -106,14 +114,14 @@ export class ConnectionService implements OnModuleInit {
|
||||
)
|
||||
) {
|
||||
models.set(
|
||||
modelDefinition.name as K,
|
||||
modelDefinition.name,
|
||||
connection.models[modelDefinition.name],
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
models.set(
|
||||
modelDefinition.name as K,
|
||||
connection.model<TournamentModelTypes[K]>(
|
||||
modelDefinition.name,
|
||||
connection.model(
|
||||
modelDefinition.name,
|
||||
modelDefinition.schema,
|
||||
modelDefinition.schemaName,
|
||||
@@ -123,7 +131,18 @@ export class ConnectionService implements OnModuleInit {
|
||||
});
|
||||
|
||||
this.tournamentModels = models;
|
||||
return models.get(modelKey) as mongoose.Model<TournamentModelTypes[K]>;
|
||||
return this.requireTournamentModel(models, modelKey);
|
||||
}
|
||||
|
||||
private requireTournamentModel<K extends keyof TournamentModelTypes>(
|
||||
models: ReadonlyMap<keyof TournamentModelTypes, unknown>,
|
||||
modelKey: K,
|
||||
): mongoose.Model<TournamentModelTypes[K]> {
|
||||
const model = models.get(modelKey);
|
||||
if (model === undefined) {
|
||||
throw new Error(`Mongoose model ${modelKey} is not registered.`);
|
||||
}
|
||||
return model as mongoose.Model<TournamentModelTypes[K]>;
|
||||
}
|
||||
|
||||
public async createSession(
|
||||
|
||||
@@ -253,9 +253,7 @@ function migrateResult(result: Record<string, unknown>) {
|
||||
seriesResults.length > 0 ? seriesResults : buildSeries(games);
|
||||
|
||||
if (typeof migrated.winnerTeamIndex !== 'number') {
|
||||
const migratedSeriesResults = Array.isArray(migrated.seriesResults)
|
||||
? migrated.seriesResults
|
||||
: [];
|
||||
const migratedSeriesResults = asArray(migrated.seriesResults);
|
||||
migrated.winnerTeamIndex =
|
||||
resolveWinnerTeamIndex(migratedSeriesResults) ??
|
||||
(isSide(migrated.winnerSide)
|
||||
|
||||
+3
-1
@@ -117,7 +117,9 @@ function createDb(params: {
|
||||
function matchesFilter(doc: Doc, filter: Record<string, unknown>): boolean {
|
||||
const clauses = filter.$or;
|
||||
if (Array.isArray(clauses)) {
|
||||
return clauses.some((clause) => matchesFilter(doc, clause));
|
||||
return (clauses as unknown[]).some(
|
||||
(clause) => isRecord(clause) && matchesFilter(doc, clause),
|
||||
);
|
||||
}
|
||||
|
||||
return Object.entries(filter).every(([key, value]) => {
|
||||
|
||||
+6
-2
@@ -11,7 +11,11 @@ import {
|
||||
} from '../../../double-elimination/double-elimination.util';
|
||||
import { TOURNAMENT_CODE_EXPIRY_MARGIN_MS } from '../../../tournament-code/tournament-code.constants';
|
||||
import { ConnectionService } from '../connection.service';
|
||||
import type { MatchDocument, TournamentCodeDocument } from '../schema';
|
||||
import type {
|
||||
MatchDocument,
|
||||
TournamentCode,
|
||||
TournamentCodeDocument,
|
||||
} from '../schema';
|
||||
import { SecretModule } from '../../secret/secret.module';
|
||||
|
||||
interface CliOptions {
|
||||
@@ -334,7 +338,7 @@ function printPlan(plan: MatchRepairPlan) {
|
||||
async function applyPlan(
|
||||
match: MatchDocument,
|
||||
plan: MatchRepairPlan,
|
||||
TournamentCodeModel: mongoose.Model<any>,
|
||||
TournamentCodeModel: mongoose.Model<TournamentCode>,
|
||||
session: mongoose.ClientSession,
|
||||
) {
|
||||
if (plan.skippedReason) return;
|
||||
|
||||
@@ -2485,7 +2485,9 @@ MatchStatsSchema.index({ communityId: 1, userIds: 1 });
|
||||
MatchStatsSchema.index({ communityId: 1, userIds: 1, scheduledAt: -1 });
|
||||
MatchStatsSchema.index({ communityId: 1, championIds: 1 });
|
||||
|
||||
export const tournamentModelDefinitions: ModelDefinition[] = [
|
||||
export const tournamentModelDefinitions: Array<
|
||||
ModelDefinition & { name: keyof TournamentModelTypes }
|
||||
> = [
|
||||
...competitionModelDefinitions,
|
||||
{ name: 'identity', schema: IdentitySchema, schemaName: 'identity' },
|
||||
{ name: 'community', schema: CommunitySchema, schemaName: 'community' },
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
export interface ModelDefinition {
|
||||
name: string;
|
||||
schema: mongoose.Schema<any>;
|
||||
schema: unknown;
|
||||
schemaName?: string;
|
||||
}
|
||||
@@ -34,10 +34,13 @@ type SchemaWithPerformanceMarker = mongoose.Schema & {
|
||||
[PERFORMANCE_PLUGIN_APPLIED]?: boolean;
|
||||
};
|
||||
|
||||
export function applyMongoosePerformancePlugin(schema: mongoose.Schema): void {
|
||||
const markedSchema = schema as SchemaWithPerformanceMarker;
|
||||
if (markedSchema[PERFORMANCE_PLUGIN_APPLIED]) return;
|
||||
markedSchema[PERFORMANCE_PLUGIN_APPLIED] = true;
|
||||
export function applyMongoosePerformancePlugin(schemaValue: unknown): void {
|
||||
if (!(schemaValue instanceof mongoose.Schema)) {
|
||||
throw new TypeError('Mongoose performance plugin requires a Schema.');
|
||||
}
|
||||
const schema = schemaValue as SchemaWithPerformanceMarker;
|
||||
if (schema[PERFORMANCE_PLUGIN_APPLIED]) return;
|
||||
schema[PERFORMANCE_PLUGIN_APPLIED] = true;
|
||||
|
||||
schema.pre(QUERY_OPERATION_REGEX, function () {
|
||||
const query = this as QueryWithPerformanceState;
|
||||
|
||||
@@ -5,10 +5,12 @@ describe('MatchService', () => {
|
||||
function createServiceWithCreateModels() {
|
||||
const createdPayloads: Record<string, unknown>[] = [];
|
||||
const MatchModel = {
|
||||
create: jest.fn().mockImplementation(async (payload) => {
|
||||
createdPayloads.push(payload);
|
||||
return payload;
|
||||
}),
|
||||
create: jest
|
||||
.fn()
|
||||
.mockImplementation(async (payload: Record<string, unknown>) => {
|
||||
createdPayloads.push(payload);
|
||||
return payload;
|
||||
}),
|
||||
exists: jest.fn().mockResolvedValue(null),
|
||||
};
|
||||
const CommunityModel = {
|
||||
|
||||
@@ -19,15 +19,15 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@lolympus/contracts": "workspace:*",
|
||||
"@azure/msal-browser": "^5.8.0",
|
||||
"@azure/msal-react": "^5.3.1",
|
||||
"@newrelic/browser-agent": "^1.316.0",
|
||||
"@lolympus/contracts": "workspace:*",
|
||||
"@newrelic/browser-agent": "^1.318.0",
|
||||
"@tanstack/react-query": "^5.100.1",
|
||||
"lucide-react": "^1.14.0",
|
||||
"react": "^19.2.4",
|
||||
"react-dom": "^19.2.4",
|
||||
"react-router": "^7.14.0",
|
||||
"react": "^19.2.8",
|
||||
"react-dom": "^19.2.8",
|
||||
"react-router": "^8.3.0",
|
||||
"recharts": "^3.8.1",
|
||||
"socket.io-client": "^4.8.3"
|
||||
},
|
||||
@@ -46,7 +46,7 @@
|
||||
"tailwindcss": "^4.2.2",
|
||||
"typescript": "~6.0.2",
|
||||
"typescript-eslint": "^8.58.0",
|
||||
"vite": "^8.0.4",
|
||||
"wrangler": "^4.85.0"
|
||||
"vite": "^8.1.5",
|
||||
"wrangler": "^4.114.0"
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { io, type Socket } from 'socket.io-client';
|
||||
import { API_BASE_URL, useAuthUserId } from '../config';
|
||||
import { acquireAccessToken } from '../lib/auth/token-provider';
|
||||
@@ -140,6 +140,9 @@ function mergeChatMessages(
|
||||
|
||||
export function useAuctionSocket(matchId: string | undefined) {
|
||||
const authUserId = useAuthUserId();
|
||||
const connectionKey = matchId
|
||||
? JSON.stringify([matchId, authUserId ?? null])
|
||||
: null;
|
||||
const socketRef = useRef<Socket | null>(null);
|
||||
const pendingBidTimeoutsRef = useRef<
|
||||
Record<string, ReturnType<typeof setTimeout>>
|
||||
@@ -166,9 +169,14 @@ export function useAuctionSocket(matchId: string | undefined) {
|
||||
Record<string, { action: string }>
|
||||
>({});
|
||||
const [resetAt, setResetAt] = useState<number | null>(null);
|
||||
const [connectionStatus, setConnectionStatus] =
|
||||
useState<ConnectionStatus>('idle');
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [connectionState, setConnectionState] = useState<{
|
||||
key: string;
|
||||
status: ConnectionStatus;
|
||||
}>({ key: '', status: 'idle' });
|
||||
const [errorState, setErrorState] = useState<{
|
||||
key: string;
|
||||
message: string | null;
|
||||
}>({ key: '', message: null });
|
||||
const [serverTimeOffsetMs, setServerTimeOffsetMs] = useState(0);
|
||||
const [serverRoundTripMs, setServerRoundTripMs] = useState<number | null>(
|
||||
null,
|
||||
@@ -176,53 +184,50 @@ export function useAuctionSocket(matchId: string | undefined) {
|
||||
const [bidLatencyDiagnostics, setBidLatencyDiagnostics] =
|
||||
useState<BidLatencyDiagnostics | null>(null);
|
||||
|
||||
function syncLatestConfirmedBidPointAmountFromAuction(
|
||||
nextAuction: ApiAuction,
|
||||
) {
|
||||
latestConfirmedBidPointAmountRef.current =
|
||||
resolveCurrentBidPointAmount(nextAuction);
|
||||
}
|
||||
const commitAuctionState = useCallback(
|
||||
(nextAuction: ApiAuction, source = 'socket-state'): boolean => {
|
||||
const currentAuction = latestAuctionRef.current;
|
||||
const applied = shouldApplyIncomingAuctionState(
|
||||
currentAuction,
|
||||
nextAuction,
|
||||
);
|
||||
const currentRevision =
|
||||
typeof currentAuction?.revision === 'number'
|
||||
? currentAuction.revision
|
||||
: -1;
|
||||
const incomingRevision =
|
||||
typeof nextAuction?.revision === 'number' ? nextAuction.revision : -1;
|
||||
// 단조성을 깨고 적용되는 경우(=revision이 같거나 뒤로 가는데도 반영됨).
|
||||
// force-resync/lifecycle 교체로만 발생하며, "2~3 버전 롤백"의 직접 증거가 된다.
|
||||
const isBackwardApply =
|
||||
applied &&
|
||||
currentRevision >= 0 &&
|
||||
incomingRevision >= 0 &&
|
||||
incomingRevision <= currentRevision;
|
||||
addNewRelicPageAction('AuctionClientStateApply', {
|
||||
matchId: matchId ?? 'none',
|
||||
source,
|
||||
applied,
|
||||
isBackwardApply,
|
||||
revisionDelta: incomingRevision - currentRevision,
|
||||
...describeAuctionForTelemetry('current', currentAuction),
|
||||
...describeAuctionForTelemetry('incoming', nextAuction),
|
||||
});
|
||||
|
||||
function commitAuctionState(
|
||||
nextAuction: ApiAuction,
|
||||
source = 'socket-state',
|
||||
): boolean {
|
||||
const currentAuction = latestAuctionRef.current;
|
||||
const applied = shouldApplyIncomingAuctionState(currentAuction, nextAuction);
|
||||
const currentRevision =
|
||||
typeof currentAuction?.revision === 'number'
|
||||
? currentAuction.revision
|
||||
: -1;
|
||||
const incomingRevision =
|
||||
typeof nextAuction?.revision === 'number' ? nextAuction.revision : -1;
|
||||
// 단조성을 깨고 적용되는 경우(=revision이 같거나 뒤로 가는데도 반영됨).
|
||||
// force-resync/lifecycle 교체로만 발생하며, "2~3 버전 롤백"의 직접 증거가 된다.
|
||||
const isBackwardApply =
|
||||
applied &&
|
||||
currentRevision >= 0 &&
|
||||
incomingRevision >= 0 &&
|
||||
incomingRevision <= currentRevision;
|
||||
addNewRelicPageAction('AuctionClientStateApply', {
|
||||
matchId: matchId ?? 'none',
|
||||
source,
|
||||
applied,
|
||||
isBackwardApply,
|
||||
revisionDelta: incomingRevision - currentRevision,
|
||||
...describeAuctionForTelemetry('current', currentAuction),
|
||||
...describeAuctionForTelemetry('incoming', nextAuction),
|
||||
});
|
||||
if (!applied) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!applied) {
|
||||
return false;
|
||||
}
|
||||
latestAuctionRef.current = nextAuction;
|
||||
latestConfirmedBidPointAmountRef.current =
|
||||
resolveCurrentBidPointAmount(nextAuction);
|
||||
setAuction(nextAuction);
|
||||
return true;
|
||||
},
|
||||
[matchId],
|
||||
);
|
||||
|
||||
latestAuctionRef.current = nextAuction;
|
||||
syncLatestConfirmedBidPointAmountFromAuction(nextAuction);
|
||||
setAuction(nextAuction);
|
||||
return true;
|
||||
}
|
||||
|
||||
function commitBidDelta(payload: BidDeltaPayload): boolean {
|
||||
const commitBidDelta = useCallback((payload: BidDeltaPayload): boolean => {
|
||||
const currentAuction = latestAuctionRef.current;
|
||||
const nextAuction = applyBidDelta(currentAuction, payload);
|
||||
if (!nextAuction || nextAuction === currentAuction) {
|
||||
@@ -230,10 +235,18 @@ export function useAuctionSocket(matchId: string | undefined) {
|
||||
}
|
||||
|
||||
latestAuctionRef.current = nextAuction;
|
||||
syncLatestConfirmedBidPointAmountFromAuction(nextAuction);
|
||||
latestConfirmedBidPointAmountRef.current =
|
||||
resolveCurrentBidPointAmount(nextAuction);
|
||||
setAuction(nextAuction);
|
||||
return true;
|
||||
}
|
||||
}, []);
|
||||
|
||||
const setError = useCallback(
|
||||
(message: string | null) => {
|
||||
setErrorState({ key: connectionKey ?? '', message });
|
||||
},
|
||||
[connectionKey],
|
||||
);
|
||||
|
||||
function applyFallbackServerTimestamp(currentServerTimestampMS?: number) {
|
||||
if (hasSyncedServerTimeRef.current) return;
|
||||
@@ -345,14 +358,47 @@ export function useAuctionSocket(matchId: string | undefined) {
|
||||
});
|
||||
}
|
||||
|
||||
const clearPendingBidRequest = useCallback((bidRequestId: string) => {
|
||||
const timeoutId = pendingBidTimeoutsRef.current[bidRequestId];
|
||||
if (timeoutId) clearTimeout(timeoutId);
|
||||
delete pendingBidTimeoutsRef.current[bidRequestId];
|
||||
setPendingBidRequests((current) => {
|
||||
const next = { ...current };
|
||||
delete next[bidRequestId];
|
||||
return next;
|
||||
});
|
||||
}, []);
|
||||
|
||||
const clearPendingActionRequest = useCallback(
|
||||
(auctionActionRequestId: string) => {
|
||||
const timeoutId =
|
||||
pendingActionTimeoutsRef.current[auctionActionRequestId];
|
||||
if (timeoutId) clearTimeout(timeoutId);
|
||||
delete pendingActionTimeoutsRef.current[auctionActionRequestId];
|
||||
setPendingActionRequests((current) => {
|
||||
const next = { ...current };
|
||||
delete next[auctionActionRequestId];
|
||||
return next;
|
||||
});
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
const clearPendingActionRequests = useCallback(() => {
|
||||
Object.values(pendingActionTimeoutsRef.current).forEach((timeoutId) =>
|
||||
clearTimeout(timeoutId),
|
||||
);
|
||||
pendingActionTimeoutsRef.current = {};
|
||||
setPendingActionRequests({});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!matchId) {
|
||||
if (!matchId || !connectionKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
const activeConnectionKey = connectionKey;
|
||||
let disposed = false;
|
||||
setConnectionStatus('connecting');
|
||||
setError(null);
|
||||
|
||||
void (async () => {
|
||||
const accessToken = await acquireAccessToken().catch((error) => {
|
||||
@@ -373,7 +419,11 @@ export function useAuctionSocket(matchId: string | undefined) {
|
||||
socketRef.current = socket;
|
||||
|
||||
socket.on('connect', () => {
|
||||
setConnectionStatus('connected');
|
||||
setConnectionState({
|
||||
key: activeConnectionKey,
|
||||
status: 'connected',
|
||||
});
|
||||
setError(null);
|
||||
socket.emit('join', { matchId });
|
||||
requestServerTimeSync(socket);
|
||||
if (timeSyncIntervalRef.current) {
|
||||
@@ -387,7 +437,10 @@ export function useAuctionSocket(matchId: string | undefined) {
|
||||
|
||||
socket.on('disconnect', () => {
|
||||
clearTimeSyncTimers();
|
||||
setConnectionStatus('disconnected');
|
||||
setConnectionState({
|
||||
key: activeConnectionKey,
|
||||
status: 'disconnected',
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('state', (nextAuction: ApiAuction) => {
|
||||
@@ -520,42 +573,20 @@ export function useAuctionSocket(matchId: string | undefined) {
|
||||
hasSyncedServerTimeRef.current = false;
|
||||
setPendingBidRequests({});
|
||||
setPendingActionRequests({});
|
||||
setConnectionStatus('idle');
|
||||
setServerTimeOffsetMs(0);
|
||||
setServerRoundTripMs(null);
|
||||
setBidLatencyDiagnostics(null);
|
||||
};
|
||||
}, [authUserId, matchId]);
|
||||
|
||||
function clearPendingBidRequest(bidRequestId: string) {
|
||||
const timeoutId = pendingBidTimeoutsRef.current[bidRequestId];
|
||||
if (timeoutId) clearTimeout(timeoutId);
|
||||
delete pendingBidTimeoutsRef.current[bidRequestId];
|
||||
setPendingBidRequests((current) => {
|
||||
const next = { ...current };
|
||||
delete next[bidRequestId];
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
function clearPendingActionRequest(auctionActionRequestId: string) {
|
||||
const timeoutId = pendingActionTimeoutsRef.current[auctionActionRequestId];
|
||||
if (timeoutId) clearTimeout(timeoutId);
|
||||
delete pendingActionTimeoutsRef.current[auctionActionRequestId];
|
||||
setPendingActionRequests((current) => {
|
||||
const next = { ...current };
|
||||
delete next[auctionActionRequestId];
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
function clearPendingActionRequests() {
|
||||
Object.values(pendingActionTimeoutsRef.current).forEach((timeoutId) =>
|
||||
clearTimeout(timeoutId),
|
||||
);
|
||||
pendingActionTimeoutsRef.current = {};
|
||||
setPendingActionRequests({});
|
||||
}
|
||||
}, [
|
||||
authUserId,
|
||||
clearPendingActionRequests,
|
||||
clearPendingBidRequest,
|
||||
commitAuctionState,
|
||||
commitBidDelta,
|
||||
connectionKey,
|
||||
matchId,
|
||||
setError,
|
||||
]);
|
||||
|
||||
function emit(eventName: string, payload?: unknown) {
|
||||
const socket = socketRef.current;
|
||||
@@ -737,9 +768,16 @@ export function useAuctionSocket(matchId: string | undefined) {
|
||||
const currentAuction = auction;
|
||||
const visibleAuction =
|
||||
currentAuction && currentAuction.matchId === matchId ? currentAuction : null;
|
||||
const visibleConnectionStatus: ConnectionStatus = matchId
|
||||
? connectionStatus
|
||||
: 'idle';
|
||||
const visibleConnectionStatus: ConnectionStatus =
|
||||
connectionKey === null
|
||||
? 'idle'
|
||||
: connectionState.key === connectionKey
|
||||
? connectionState.status
|
||||
: 'connecting';
|
||||
const visibleError =
|
||||
connectionKey !== null && errorState.key === connectionKey
|
||||
? errorState.message
|
||||
: null;
|
||||
|
||||
return {
|
||||
auction: visibleAuction,
|
||||
@@ -750,7 +788,7 @@ export function useAuctionSocket(matchId: string | undefined) {
|
||||
pendingBidRequests,
|
||||
resetAt,
|
||||
connectionStatus: visibleConnectionStatus,
|
||||
error,
|
||||
error: visibleError,
|
||||
bidLatencyDiagnostics,
|
||||
serverRoundTripMs: matchId ? serverRoundTripMs : null,
|
||||
serverTimeOffsetMs: matchId ? serverTimeOffsetMs : 0,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { io, type Socket } from 'socket.io-client';
|
||||
import { io } from 'socket.io-client';
|
||||
import { API_BASE_URL } from '../config';
|
||||
import type { ApiRiotRefreshEvent } from './types';
|
||||
|
||||
@@ -19,37 +19,43 @@ export function useRiotRefreshSocket({
|
||||
parentJobId?: string;
|
||||
onEvent: (event: ApiRiotRefreshEvent) => void;
|
||||
}) {
|
||||
const socketRef = useRef<Socket | null>(null);
|
||||
const subscriptionKey =
|
||||
puuid || parentJobId ? JSON.stringify([puuid, parentJobId]) : null;
|
||||
const onEventRef = useRef(onEvent);
|
||||
const [connectionStatus, setConnectionStatus] =
|
||||
useState<ConnectionStatus>('idle');
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [connectionState, setConnectionState] = useState<{
|
||||
key: string;
|
||||
status: ConnectionStatus;
|
||||
error: string | null;
|
||||
}>({ key: '', status: 'idle', error: null });
|
||||
|
||||
useEffect(() => {
|
||||
onEventRef.current = onEvent;
|
||||
}, [onEvent]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!puuid && !parentJobId) {
|
||||
setConnectionStatus('idle');
|
||||
if (!subscriptionKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
setConnectionStatus('connecting');
|
||||
setError(null);
|
||||
|
||||
const socket = io(`${API_BASE_URL}/riot-refresh`, {
|
||||
transports: ['websocket'],
|
||||
});
|
||||
socketRef.current = socket;
|
||||
|
||||
socket.on('connect', () => {
|
||||
setConnectionStatus('connected');
|
||||
setConnectionState({
|
||||
key: subscriptionKey,
|
||||
status: 'connected',
|
||||
error: null,
|
||||
});
|
||||
socket.emit('subscribe', { puuid, parentJobId });
|
||||
});
|
||||
|
||||
socket.on('disconnect', () => {
|
||||
setConnectionStatus('disconnected');
|
||||
setConnectionState((current) => ({
|
||||
key: subscriptionKey,
|
||||
status: 'disconnected',
|
||||
error: current.key === subscriptionKey ? current.error : null,
|
||||
}));
|
||||
});
|
||||
|
||||
socket.on('riot-refresh', (event: ApiRiotRefreshEvent) => {
|
||||
@@ -57,17 +63,29 @@ export function useRiotRefreshSocket({
|
||||
});
|
||||
|
||||
socket.on('error', (payload: { message?: string }) => {
|
||||
setConnectionStatus('error');
|
||||
setError(payload.message ?? '전적 갱신 소켓 연결 중 오류가 발생했습니다.');
|
||||
setConnectionState({
|
||||
key: subscriptionKey,
|
||||
status: 'error',
|
||||
error:
|
||||
payload.message ?? '전적 갱신 소켓 연결 중 오류가 발생했습니다.',
|
||||
});
|
||||
});
|
||||
|
||||
return () => {
|
||||
socket.removeAllListeners();
|
||||
socket.disconnect();
|
||||
socketRef.current = null;
|
||||
setConnectionStatus('idle');
|
||||
};
|
||||
}, [parentJobId, puuid]);
|
||||
}, [parentJobId, puuid, subscriptionKey]);
|
||||
|
||||
return { connectionStatus, error };
|
||||
const hasCurrentConnection =
|
||||
subscriptionKey !== null && connectionState.key === subscriptionKey;
|
||||
return {
|
||||
connectionStatus:
|
||||
subscriptionKey === null
|
||||
? 'idle'
|
||||
: hasCurrentConnection
|
||||
? connectionState.status
|
||||
: 'connecting',
|
||||
error: hasCurrentConnection ? connectionState.error : null,
|
||||
};
|
||||
}
|
||||
@@ -1,20 +1,30 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useState } from 'react';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import { setAuthUserId, useAuthUserId } from '../config';
|
||||
|
||||
export default function DevAuthSwitcher() {
|
||||
const authUserId = useAuthUserId();
|
||||
const queryClient = useQueryClient();
|
||||
const [inputValue, setInputValue] = useState(authUserId ?? '');
|
||||
|
||||
useEffect(() => {
|
||||
setInputValue(authUserId ?? '');
|
||||
}, [authUserId]);
|
||||
|
||||
if (!import.meta.env.DEV) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<DevAuthSwitcherForm
|
||||
key={authUserId ?? 'no-auth-user'}
|
||||
authUserId={authUserId}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function DevAuthSwitcherForm({
|
||||
authUserId,
|
||||
}: {
|
||||
authUserId: string | null;
|
||||
}) {
|
||||
const queryClient = useQueryClient();
|
||||
const [inputValue, setInputValue] = useState(authUserId ?? '');
|
||||
|
||||
function updateAuthUserId(nextValue: string | null) {
|
||||
setAuthUserId(nextValue);
|
||||
void queryClient.invalidateQueries();
|
||||
|
||||
@@ -1,21 +1,9 @@
|
||||
import type { ApiTierInfo } from "../api/types";
|
||||
import { formatRankBadge, formatRankDetail } from "./rankBadgeUtils";
|
||||
|
||||
type RankBadgeSize = "sm" | "md";
|
||||
type RankBadgeTooltipPlacement = "left" | "bottom";
|
||||
|
||||
const TIER_NAMES: Record<string, string> = {
|
||||
IRON: "아이언",
|
||||
BRONZE: "브론즈",
|
||||
SILVER: "실버",
|
||||
GOLD: "골드",
|
||||
PLATINUM: "플래티넘",
|
||||
EMERALD: "에메랄드",
|
||||
DIAMOND: "다이아몬드",
|
||||
MASTER: "마스터",
|
||||
GRANDMASTER: "그랜드마스터",
|
||||
CHALLENGER: "챌린저",
|
||||
};
|
||||
|
||||
const SIZE_CLASSES: Record<RankBadgeSize, string> = {
|
||||
sm: "h-[17px] min-w-[18px]",
|
||||
md: "h-[18px] min-w-[20px]",
|
||||
@@ -26,21 +14,6 @@ const TOOLTIP_CLASSES: Record<RankBadgeTooltipPlacement, string> = {
|
||||
bottom: "tooltip-bottom",
|
||||
};
|
||||
|
||||
function normalizeRank(rank: string | undefined) {
|
||||
switch (rank) {
|
||||
case "I":
|
||||
return "1";
|
||||
case "II":
|
||||
return "2";
|
||||
case "III":
|
||||
return "3";
|
||||
case "IV":
|
||||
return "4";
|
||||
default:
|
||||
return rank;
|
||||
}
|
||||
}
|
||||
|
||||
function rankBadgeClass(tier: ApiTierInfo | undefined) {
|
||||
switch (tier?.tier) {
|
||||
case "CHALLENGER":
|
||||
@@ -68,22 +41,6 @@ function rankBadgeClass(tier: ApiTierInfo | undefined) {
|
||||
}
|
||||
}
|
||||
|
||||
export function formatRankBadge(tier: ApiTierInfo | undefined) {
|
||||
if (!tier) return "U";
|
||||
const tierInitial =
|
||||
tier.tier === "GRANDMASTER" ? "GM" : tier.tier.slice(0, 1);
|
||||
const rank = normalizeRank(tier.rank);
|
||||
return rank ? `${tierInitial}${rank}` : tierInitial;
|
||||
}
|
||||
|
||||
export function formatRankDetail(tier: ApiTierInfo | undefined) {
|
||||
if (!tier) return "랭크 정보 없음";
|
||||
const tierName = TIER_NAMES[tier.tier] ?? tier.tier;
|
||||
const rank = normalizeRank(tier.rank);
|
||||
const label = rank ? `${tierName} ${rank}` : tierName;
|
||||
return `${label} - ${tier.leaguePoints} LP`;
|
||||
}
|
||||
|
||||
export function RankBadge({
|
||||
tier,
|
||||
size = "md",
|
||||
|
||||
@@ -67,6 +67,7 @@ const TIER_COMPACT_NAMES: Record<string, string> = {
|
||||
};
|
||||
|
||||
type PeriodKey = "30" | "90" | "all";
|
||||
type PeriodFilter = { key: PeriodKey; cutoffTimestamp: number };
|
||||
type SummaryVariant = "footer" | "inline";
|
||||
type SummaryDirection = "up" | "down" | "flat";
|
||||
|
||||
@@ -314,18 +315,17 @@ export default function TierHistoryChart({
|
||||
const [queue, setQueue] = useState(
|
||||
availableQueues[0] ?? "RANKED_SOLO_5x5",
|
||||
);
|
||||
const [period, setPeriod] = useState<PeriodKey>("all");
|
||||
const [periodFilter, setPeriodFilter] = useState<PeriodFilter>({
|
||||
key: "all",
|
||||
cutoffTimestamp: 0,
|
||||
});
|
||||
const period = periodFilter.key;
|
||||
|
||||
const activeQueue = availableQueues.includes(queue)
|
||||
? queue
|
||||
: (availableQueues[0] ?? "RANKED_SOLO_5x5");
|
||||
|
||||
const points = useMemo<ChartPoint[]>(() => {
|
||||
const periodDays =
|
||||
PERIOD_OPTIONS.find((option) => option.key === period)?.days ?? null;
|
||||
const cutoff =
|
||||
periodDays === null ? 0 : Date.now() - periodDays * 24 * 60 * 60 * 1000;
|
||||
|
||||
return entries
|
||||
.filter((entry) => entry.queueType === activeQueue)
|
||||
.map((entry) => ({
|
||||
@@ -337,9 +337,9 @@ export default function TierHistoryChart({
|
||||
wins: entry.wins,
|
||||
losses: entry.losses,
|
||||
}))
|
||||
.filter((point) => point.ts >= cutoff)
|
||||
.filter((point) => point.ts >= periodFilter.cutoffTimestamp)
|
||||
.sort((left, right) => left.ts - right.ts);
|
||||
}, [entries, activeQueue, period]);
|
||||
}, [entries, activeQueue, periodFilter.cutoffTimestamp]);
|
||||
|
||||
// 티어 경계(가로 점선) 후보 — 데이터 범위 안에 드는 티어 floor만.
|
||||
const tierLines = useMemo(() => {
|
||||
@@ -408,7 +408,19 @@ export default function TierHistoryChart({
|
||||
<select
|
||||
className="h-7 border border-base-content/10 bg-base-100 px-2 text-xs text-base-content focus:border-primary/30 focus:outline-none"
|
||||
value={period}
|
||||
onChange={(event) => setPeriod(event.target.value as PeriodKey)}
|
||||
onChange={(event) => {
|
||||
const nextPeriod = event.target.value as PeriodKey;
|
||||
const days =
|
||||
PERIOD_OPTIONS.find((option) => option.key === nextPeriod)
|
||||
?.days ?? null;
|
||||
setPeriodFilter({
|
||||
key: nextPeriod,
|
||||
cutoffTimestamp:
|
||||
days === null
|
||||
? 0
|
||||
: Date.now() - days * 24 * 60 * 60 * 1000,
|
||||
});
|
||||
}}
|
||||
>
|
||||
{PERIOD_OPTIONS.map((option) => (
|
||||
<option key={option.key} value={option.key}>
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import type { ApiTierInfo } from "../api/types";
|
||||
|
||||
const TIER_NAMES: Record<string, string> = {
|
||||
IRON: "아이언",
|
||||
BRONZE: "브론즈",
|
||||
SILVER: "실버",
|
||||
GOLD: "골드",
|
||||
PLATINUM: "플래티넘",
|
||||
EMERALD: "에메랄드",
|
||||
DIAMOND: "다이아몬드",
|
||||
MASTER: "마스터",
|
||||
GRANDMASTER: "그랜드마스터",
|
||||
CHALLENGER: "챌린저",
|
||||
};
|
||||
|
||||
function normalizeRank(rank: string | undefined) {
|
||||
switch (rank) {
|
||||
case "I":
|
||||
return "1";
|
||||
case "II":
|
||||
return "2";
|
||||
case "III":
|
||||
return "3";
|
||||
case "IV":
|
||||
return "4";
|
||||
default:
|
||||
return rank;
|
||||
}
|
||||
}
|
||||
|
||||
export function formatRankBadge(tier: ApiTierInfo | undefined) {
|
||||
if (!tier) return "U";
|
||||
const tierInitial =
|
||||
tier.tier === "GRANDMASTER" ? "GM" : tier.tier.slice(0, 1);
|
||||
const rank = normalizeRank(tier.rank);
|
||||
return rank ? `${tierInitial}${rank}` : tierInitial;
|
||||
}
|
||||
|
||||
export function formatRankDetail(tier: ApiTierInfo | undefined) {
|
||||
if (!tier) return "랭크 정보 없음";
|
||||
const tierName = TIER_NAMES[tier.tier] ?? tier.tier;
|
||||
const rank = normalizeRank(tier.rank);
|
||||
const label = rank ? `${tierName} ${rank}` : tierName;
|
||||
return `${label} - ${tier.leaguePoints} LP`;
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
lazy,
|
||||
memo,
|
||||
Suspense,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
@@ -51,7 +52,8 @@ import {
|
||||
teamIndexLabel,
|
||||
} from "../lib/league";
|
||||
import { internalMatchGamePath } from "../lib/internal-match-routes";
|
||||
import { formatRankDetail, RankBadge } from "../components/RankBadge";
|
||||
import { RankBadge } from "../components/RankBadge";
|
||||
import { formatRankDetail } from "../components/rankBadgeUtils";
|
||||
import type {
|
||||
ApiAuction,
|
||||
ApiAuctionChatMessage,
|
||||
@@ -1616,7 +1618,6 @@ function BidControls({
|
||||
serverTimeOffsetMs: number;
|
||||
onBid: (teamIndex: number, amount: number) => void;
|
||||
}) {
|
||||
const [bidAmount, setBidAmount] = useState(100);
|
||||
const minBid = state.currentBid + AUCTION_MIN_BID_POINTS;
|
||||
const activeTeam = captainRole
|
||||
? state.teams.find((team) => team.teamIndex === captainRole.teamIndex)
|
||||
@@ -1627,6 +1628,23 @@ function BidControls({
|
||||
? getReservedPointsAfterCurrentBid(activeTeam)
|
||||
: 0;
|
||||
const maxBid = activeTeam ? getMaxBidForTeam(activeTeam) : 0;
|
||||
const defaultBidAmount = Math.max(minBid, Math.ceil(minBid / 10) * 10);
|
||||
const bidContextKey = `${activeTeam?.teamIndex ?? "spectator"}:${maxBid}:${minBid}`;
|
||||
const [bidDraft, setBidDraft] = useState({
|
||||
contextKey: bidContextKey,
|
||||
amount: activeTeam
|
||||
? Math.min(maxBid, defaultBidAmount)
|
||||
: defaultBidAmount,
|
||||
});
|
||||
const bidAmount =
|
||||
bidDraft.contextKey === bidContextKey
|
||||
? bidDraft.amount
|
||||
: activeTeam
|
||||
? Math.min(maxBid, defaultBidAmount)
|
||||
: defaultBidAmount;
|
||||
const setBidAmount = (amount: number) => {
|
||||
setBidDraft({ contextKey: bidContextKey, amount });
|
||||
};
|
||||
const canAffordNextBid = !isActiveTeamFull && maxBid >= minBid;
|
||||
const isBidExpired = useIsDeadlineExpired(
|
||||
state.deadline,
|
||||
@@ -1637,11 +1655,6 @@ function BidControls({
|
||||
? Math.min(maxBid, Math.max(minBid, bidAmount))
|
||||
: Math.max(minBid, bidAmount);
|
||||
|
||||
useEffect(() => {
|
||||
const nextBid = Math.max(minBid, Math.ceil(minBid / 10) * 10);
|
||||
setBidAmount(activeTeam ? Math.min(maxBid, nextBid) : nextBid);
|
||||
}, [activeTeam, maxBid, minBid]);
|
||||
|
||||
if (state.phase !== "bidding") return null;
|
||||
|
||||
if (!activeTeam) {
|
||||
@@ -1843,7 +1856,10 @@ export default function AuctionPage() {
|
||||
const resetAuctionMutation = useResetAuction(DEFAULT_COMMUNITY_ID);
|
||||
const socket = useAuctionSocket(id);
|
||||
const captainTeamIndex = useDevCaptainTeamIndex();
|
||||
const [assignedPosition, setAssignedPosition] = useState<Position>("MID");
|
||||
const [assignedPositionDraft, setAssignedPositionDraft] = useState<{
|
||||
playerId: string | null;
|
||||
position: Position;
|
||||
}>({ playerId: null, position: "MID" });
|
||||
const [showCancelModal, setShowCancelModal] = useState(false);
|
||||
const [cancelConfirmText, setCancelConfirmText] = useState("");
|
||||
const [undoTargetSequence, setUndoTargetSequence] = useState<number | null>(
|
||||
@@ -1853,7 +1869,7 @@ export default function AuctionPage() {
|
||||
const historyBackTo = `${location.pathname}${location.search}${location.hash}`;
|
||||
const canConfirmAuctionCancel = cancelConfirmText.trim() === "예";
|
||||
|
||||
async function clearAuctionDataAfterCancel() {
|
||||
const clearAuctionDataAfterCancel = useCallback(async () => {
|
||||
if (!id) return;
|
||||
const auctionQueryKey = ["auction", DEFAULT_COMMUNITY_ID, id] as const;
|
||||
const auctionHistoryQueryKey = [
|
||||
@@ -1878,7 +1894,7 @@ export default function AuctionPage() {
|
||||
queryKey: ["match", DEFAULT_COMMUNITY_ID, id],
|
||||
exact: true,
|
||||
});
|
||||
}
|
||||
}, [id, queryClient]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!showCancelModal) return;
|
||||
@@ -1893,6 +1909,14 @@ export default function AuctionPage() {
|
||||
: null,
|
||||
[liveAuction, matchQuery.data],
|
||||
);
|
||||
const currentPlayerId = auctionState?.currentPlayer?.id ?? null;
|
||||
const assignedPosition =
|
||||
assignedPositionDraft.playerId === currentPlayerId
|
||||
? assignedPositionDraft.position
|
||||
: (auctionState?.currentPlayer?.mainPosition ?? "MID");
|
||||
const setAssignedPosition = (position: Position) => {
|
||||
setAssignedPositionDraft({ playerId: currentPlayerId, position });
|
||||
};
|
||||
const availableTeamIndexes = useMemo(() => {
|
||||
const indexes = new Set(
|
||||
(auctionState?.teams ?? []).map((team) => team.teamIndex),
|
||||
@@ -1907,12 +1931,6 @@ export default function AuctionPage() {
|
||||
};
|
||||
const chatSenderLabel = resolveChatSenderLabel(currentUser, captainRole);
|
||||
|
||||
useEffect(() => {
|
||||
if (auctionState?.currentPlayer) {
|
||||
setAssignedPosition(auctionState.currentPlayer.mainPosition);
|
||||
}
|
||||
}, [auctionState?.currentPlayer?.id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (availableTeamIndexes.length === 0) return;
|
||||
if (
|
||||
@@ -1928,7 +1946,7 @@ export default function AuctionPage() {
|
||||
void clearAuctionDataAfterCancel().finally(() => {
|
||||
navigate(`/match/${id}`, { replace: true });
|
||||
});
|
||||
}, [id, navigate, socket.resetAt]);
|
||||
}, [clearAuctionDataAfterCancel, id, navigate, socket.resetAt]);
|
||||
|
||||
if (!DEFAULT_COMMUNITY_ID) {
|
||||
return (
|
||||
|
||||
@@ -85,7 +85,6 @@ function HistoryTableColGroup() {
|
||||
<col className="w-[88px]" />
|
||||
<col className="w-[132px]" />
|
||||
<col className="w-[72px]" />
|
||||
<col className="w-[116px]" />
|
||||
</colgroup>
|
||||
);
|
||||
}
|
||||
@@ -99,7 +98,6 @@ function HistoryTableHeader() {
|
||||
<th className="py-2.5 px-4 font-semibold">상태</th>
|
||||
<th className="py-2.5 px-4 font-semibold">맵</th>
|
||||
<th className="py-2.5 px-4 font-semibold">참가</th>
|
||||
<th className="py-2.5 px-4 font-semibold">결과</th>
|
||||
</tr>
|
||||
</thead>
|
||||
);
|
||||
@@ -156,14 +154,6 @@ function HistoryRecordsSkeleton({
|
||||
10명
|
||||
</SkeletonText>
|
||||
</td>
|
||||
<td className="py-2.5 px-4 text-xs text-base-content/50 whitespace-nowrap">
|
||||
<SkeletonText
|
||||
className="truncate"
|
||||
skeletonClassName="h-[1em] w-14"
|
||||
>
|
||||
1팀 승리
|
||||
</SkeletonText>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
@@ -205,10 +195,6 @@ function HistoryRecordsSkeleton({
|
||||
<SkeletonText skeletonClassName="h-[1em] w-8">
|
||||
10명
|
||||
</SkeletonText>
|
||||
<span className="invisible text-base-content/20">·</span>
|
||||
<SkeletonText skeletonClassName="h-[1em] w-14">
|
||||
1팀 승리
|
||||
</SkeletonText>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -682,20 +668,12 @@ export default function HomePage() {
|
||||
<td className="py-2.5 px-4 text-xs text-base-content/50 whitespace-nowrap">
|
||||
{match.participants.length}명
|
||||
</td>
|
||||
<td className="py-2.5 px-4 text-xs text-base-content/50 whitespace-nowrap">
|
||||
<Link
|
||||
to={`/match/${match.id}`}
|
||||
className="font-semibold text-base-content/45 hover:text-primary"
|
||||
>
|
||||
공식 결과
|
||||
</Link>
|
||||
</td>
|
||||
</tr>
|
||||
))
|
||||
) : (
|
||||
<tr>
|
||||
<td
|
||||
colSpan={6}
|
||||
colSpan={5}
|
||||
className="py-6 px-4 text-sm text-base-content/35 text-center"
|
||||
>
|
||||
아직 내전 기록이 없습니다.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import { Link, useParams } from 'react-router';
|
||||
import {
|
||||
@@ -8,11 +8,17 @@ import {
|
||||
useMe,
|
||||
useStartLegacyImport,
|
||||
} from '../../api/hooks';
|
||||
import type { LegacyImportJob, StartLegacyImportRequest } from '../../api/types';
|
||||
import type {
|
||||
LegacyImportJob,
|
||||
LegacyImportMemberWindow,
|
||||
StartLegacyImportRequest,
|
||||
} from '../../api/types';
|
||||
import { DEFAULT_COMMUNITY_ID } from '../../config';
|
||||
|
||||
const DEFAULT_START = '2024-05-01T00:00:00.000Z';
|
||||
|
||||
type MemberWindowOverride = { startTime: string; endTime: string };
|
||||
|
||||
function toInputValue(value: string) {
|
||||
const date = new Date(value);
|
||||
const local = new Date(date.getTime() - date.getTimezoneOffset() * 60_000);
|
||||
@@ -44,6 +50,15 @@ function progress(job: LegacyImportJob) {
|
||||
return Math.round((job.processedMembers / job.totalMembers) * 100);
|
||||
}
|
||||
|
||||
function defaultMemberOverride(
|
||||
member: LegacyImportMemberWindow,
|
||||
): MemberWindowOverride {
|
||||
return {
|
||||
startTime: toInputValue(member.startTime),
|
||||
endTime: toInputValue(member.endTime),
|
||||
};
|
||||
}
|
||||
|
||||
function JobCard({
|
||||
job,
|
||||
onCancel,
|
||||
@@ -111,7 +126,7 @@ export default function LegacyImportPage() {
|
||||
const [windowEnd, setWindowEnd] = useState('');
|
||||
const [message, setMessage] = useState<string | null>(null);
|
||||
const [overrides, setOverrides] = useState<
|
||||
Record<string, { startTime: string; endTime: string }>
|
||||
Record<string, MemberWindowOverride>
|
||||
>({});
|
||||
const currentUser =
|
||||
meQuery.data?.memberships.find(
|
||||
@@ -131,20 +146,6 @@ export default function LegacyImportPage() {
|
||||
const cancelMutation = useCancelLegacyImport(communityId);
|
||||
const members = membersQuery.data?.members ?? [];
|
||||
|
||||
useEffect(() => {
|
||||
setOverrides(
|
||||
Object.fromEntries(
|
||||
members.map((member) => [
|
||||
member.userId,
|
||||
{
|
||||
startTime: toInputValue(member.startTime),
|
||||
endTime: toInputValue(member.endTime),
|
||||
},
|
||||
]),
|
||||
),
|
||||
);
|
||||
}, [members]);
|
||||
|
||||
const manageableMemberships =
|
||||
meQuery.data?.memberships.filter((membership) => {
|
||||
const role = membership.user.role;
|
||||
@@ -180,11 +181,15 @@ export default function LegacyImportPage() {
|
||||
const payload: StartLegacyImportRequest = {
|
||||
windowStart: fromInputValue(windowStart),
|
||||
windowEnd: fromInputValue(windowEnd),
|
||||
memberOverrides: members.map((member) => ({
|
||||
userId: member.userId,
|
||||
startTime: fromInputValue(overrides[member.userId]?.startTime ?? ''),
|
||||
endTime: fromInputValue(overrides[member.userId]?.endTime ?? ''),
|
||||
})),
|
||||
memberOverrides: members.map((member) => {
|
||||
const override =
|
||||
overrides[member.userId] ?? defaultMemberOverride(member);
|
||||
return {
|
||||
userId: member.userId,
|
||||
startTime: fromInputValue(override.startTime),
|
||||
endTime: fromInputValue(override.endTime),
|
||||
};
|
||||
}),
|
||||
};
|
||||
startMutation.mutate(payload, {
|
||||
onSuccess: async (result) => {
|
||||
@@ -323,53 +328,68 @@ export default function LegacyImportPage() {
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{members.map((member) => (
|
||||
<tr key={member.userId} className="border-b border-base-content/5">
|
||||
<td className="px-3 py-2 text-sm font-bold">
|
||||
{member.displayName}
|
||||
</td>
|
||||
<td className="px-3 py-2 text-xs text-base-content/45">
|
||||
{member.gameName}#{member.tagLine}
|
||||
</td>
|
||||
<td className="px-3 py-2 text-xs">
|
||||
{member.isActivated ? '활성' : '비활성'}
|
||||
</td>
|
||||
<td className="px-3 py-2">
|
||||
<input
|
||||
type="datetime-local"
|
||||
value={overrides[member.userId]?.startTime ?? ''}
|
||||
onChange={(event) =>
|
||||
setOverrides((current) => ({
|
||||
...current,
|
||||
[member.userId]: {
|
||||
...current[member.userId],
|
||||
startTime: event.target.value,
|
||||
endTime: current[member.userId]?.endTime ?? '',
|
||||
},
|
||||
}))
|
||||
}
|
||||
className="border border-base-content/10 bg-transparent px-2 py-1 text-xs"
|
||||
/>
|
||||
</td>
|
||||
<td className="px-3 py-2">
|
||||
<input
|
||||
type="datetime-local"
|
||||
value={overrides[member.userId]?.endTime ?? ''}
|
||||
onChange={(event) =>
|
||||
setOverrides((current) => ({
|
||||
...current,
|
||||
[member.userId]: {
|
||||
...current[member.userId],
|
||||
startTime: current[member.userId]?.startTime ?? '',
|
||||
endTime: event.target.value,
|
||||
},
|
||||
}))
|
||||
}
|
||||
className="border border-base-content/10 bg-transparent px-2 py-1 text-xs"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
{members.map((member) => {
|
||||
const override =
|
||||
overrides[member.userId] ?? defaultMemberOverride(member);
|
||||
return (
|
||||
<tr
|
||||
key={member.userId}
|
||||
className="border-b border-base-content/5"
|
||||
>
|
||||
<td className="px-3 py-2 text-sm font-bold">
|
||||
{member.displayName}
|
||||
</td>
|
||||
<td className="px-3 py-2 text-xs text-base-content/45">
|
||||
{member.gameName}#{member.tagLine}
|
||||
</td>
|
||||
<td className="px-3 py-2 text-xs">
|
||||
{member.isActivated ? '활성' : '비활성'}
|
||||
</td>
|
||||
<td className="px-3 py-2">
|
||||
<input
|
||||
type="datetime-local"
|
||||
value={override.startTime}
|
||||
onChange={(event) =>
|
||||
setOverrides((current) => {
|
||||
const currentOverride =
|
||||
current[member.userId] ??
|
||||
defaultMemberOverride(member);
|
||||
return {
|
||||
...current,
|
||||
[member.userId]: {
|
||||
...currentOverride,
|
||||
startTime: event.target.value,
|
||||
},
|
||||
};
|
||||
})
|
||||
}
|
||||
className="border border-base-content/10 bg-transparent px-2 py-1 text-xs"
|
||||
/>
|
||||
</td>
|
||||
<td className="px-3 py-2">
|
||||
<input
|
||||
type="datetime-local"
|
||||
value={override.endTime}
|
||||
onChange={(event) =>
|
||||
setOverrides((current) => {
|
||||
const currentOverride =
|
||||
current[member.userId] ??
|
||||
defaultMemberOverride(member);
|
||||
return {
|
||||
...current,
|
||||
[member.userId]: {
|
||||
...currentOverride,
|
||||
endTime: event.target.value,
|
||||
},
|
||||
};
|
||||
})
|
||||
}
|
||||
className="border border-base-content/10 bg-transparent px-2 py-1 text-xs"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
{members.length === 0 && (
|
||||
<tr>
|
||||
<td colSpan={5} className="px-4 py-8 text-center text-sm text-base-content/35">
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
|
||||
const homePageSource = await readFile(
|
||||
new URL("../src/pages/HomePage.tsx", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
test("keeps past match history focused on the five summary columns", () => {
|
||||
const colGroup = sourceForFunction("HistoryTableColGroup");
|
||||
const header = sourceForFunction("HistoryTableHeader");
|
||||
const skeleton = sourceForFunction("HistoryRecordsSkeleton");
|
||||
|
||||
assert.equal(colGroup.match(/<col(?:\s|\/|>)/g)?.length, 5);
|
||||
assert.doesNotMatch(header, />결과<\/th>/);
|
||||
assert.doesNotMatch(homePageSource, /공식 결과/);
|
||||
assert.doesNotMatch(skeleton, /1팀 승리/);
|
||||
assert.match(homePageSource, /colSpan=\{5\}/);
|
||||
});
|
||||
|
||||
function sourceForFunction(name: string): string {
|
||||
const start = homePageSource.indexOf(`function ${name}(`);
|
||||
assert.notEqual(start, -1, `${name} should exist`);
|
||||
|
||||
const nextFunction = homePageSource.indexOf("\nfunction ", start + 1);
|
||||
assert.notEqual(nextFunction, -1, `${name} should have a following function`);
|
||||
return homePageSource.slice(start, nextFunction);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
# Dependency Audit Exceptions
|
||||
|
||||
## GHSA-mh99-v99m-4gvg
|
||||
|
||||
- Package: `brace-expansion`
|
||||
- Scope: development tooling only (`eslint`, `jest`, and `@nestjs/cli` through
|
||||
`minimatch`/`glob`)
|
||||
- Production exposure: none; `pnpm audit --prod --audit-level high` reports no
|
||||
high or critical findings
|
||||
- Reason: the only patched release is `brace-expansion@5.0.8`, whose CommonJS
|
||||
API is incompatible with the affected `minimatch@3` and `minimatch@9`
|
||||
consumers
|
||||
- Mitigation: repository-controlled glob patterns are trusted; no
|
||||
attacker-controlled input is passed to these development tools
|
||||
- Review date: 2026-08-25
|
||||
- Removal condition: remove the audit exception once the upstream toolchain
|
||||
supports `brace-expansion@5.0.8` or publishes compatible patched releases
|
||||
|
||||
## Tracked remediation
|
||||
|
||||
### GHSA-664h-wqgq-64gw
|
||||
|
||||
- Package: `mongoose@9.4.1`
|
||||
- Severity: moderate
|
||||
- Patched version: `>=9.7.2`
|
||||
- Status: not ignored; it remains visible in a full audit and does not fail the
|
||||
high-severity CI gate
|
||||
- Upgrade blocker: Mongoose 9.7.x tightens create and query types and currently
|
||||
causes API compilation failures across the model layer
|
||||
- Next action: migrate the affected model create/query types, then upgrade
|
||||
Mongoose in a dedicated change
|
||||
- Review date: 2026-08-25
|
||||
@@ -0,0 +1,67 @@
|
||||
# Spec: Dakao Upcoming Internal Match List
|
||||
|
||||
## Objective
|
||||
|
||||
When a user sends `!내전 일정`, return only recruiting matches whose scheduled
|
||||
start is not earlier than the command processing time. Matches that have already
|
||||
started must not consume the ten-result query limit or appear in the response.
|
||||
|
||||
## Approved Product Decisions
|
||||
|
||||
- Capture the command processing time once before querying matches.
|
||||
- Exclude `scheduledAt < now`.
|
||||
- Include `scheduledAt === now` and future matches.
|
||||
- Apply the boundary only to the Dakao `!내전 일정` command.
|
||||
- Preserve the existing recruiting status, result limit, ordering, formatting,
|
||||
short-code generation, and short-link behavior.
|
||||
|
||||
## Commands
|
||||
|
||||
- Focused test:
|
||||
`pnpm --filter api exec jest src/modules/dakao/handlers/match-list.handler.spec.ts --runInBand`
|
||||
- API lint:
|
||||
`pnpm --filter api exec eslint "{src,apps,libs,test}/**/*.ts" --max-warnings=0`
|
||||
- API build: `pnpm --filter api build`
|
||||
|
||||
## Project Structure
|
||||
|
||||
- `apps/api/src/modules/dakao/handlers/match-list.handler.ts` owns the command
|
||||
query and response formatting.
|
||||
- `apps/api/src/modules/dakao/handlers/match-list.handler.spec.ts` verifies the
|
||||
command boundary and presentation.
|
||||
- `apps/api/src/modules/match/match.service.ts` translates `scheduledFrom` into a
|
||||
MongoDB `$gte` filter.
|
||||
|
||||
## Code Style
|
||||
|
||||
Pass the captured boundary through the existing list contract:
|
||||
|
||||
```ts
|
||||
const scheduledFrom = new Date();
|
||||
await matchService.list({ communityId, scheduledFrom });
|
||||
```
|
||||
|
||||
## Testing Strategy
|
||||
|
||||
- Freeze the system clock in the handler unit test.
|
||||
- Assert that the exact frozen time is passed as `scheduledFrom`.
|
||||
- Rely on the existing `MatchService` test that verifies `scheduledFrom` becomes
|
||||
`{ scheduledAt: { $gte: scheduledFrom } }`.
|
||||
- Run the focused handler test, full API lint, and API build.
|
||||
|
||||
## Boundaries
|
||||
|
||||
- Always: filter before applying the result limit and use one captured time.
|
||||
- Ask first: change ordering, statuses, limit, or response wording.
|
||||
- Never: hide the requirement with an ESLint exception or filter only after the
|
||||
limited database query.
|
||||
|
||||
## Success Criteria
|
||||
|
||||
- A match scheduled before command processing time is not queried.
|
||||
- A match scheduled exactly at command processing time remains eligible.
|
||||
- Existing command formatting and link tests continue to pass.
|
||||
|
||||
## Open Questions
|
||||
|
||||
None.
|
||||
+21
-1
@@ -26,6 +26,26 @@
|
||||
},
|
||||
"packageManager": "pnpm@10.4.1",
|
||||
"dependencies": {
|
||||
"@infisical/sdk": "^5.0.0"
|
||||
"@infisical/sdk": "^5.0.2"
|
||||
},
|
||||
"pnpm": {
|
||||
"auditConfig": {
|
||||
"ignoreGhsas": [
|
||||
"GHSA-mh99-v99m-4gvg"
|
||||
]
|
||||
},
|
||||
"overrides": {
|
||||
"@babel/core@7.29.0": "7.29.6",
|
||||
"brace-expansion@1.1.13": "1.1.16",
|
||||
"brace-expansion@2.0.3": "2.1.2",
|
||||
"brace-expansion@5.0.5": "5.0.8",
|
||||
"engine.io@6.6.6": "6.6.7",
|
||||
"fast-uri@3.1.0": "3.1.4",
|
||||
"form-data@4.0.5": "4.0.6",
|
||||
"js-yaml@4.1.1": "4.3.0",
|
||||
"js-yaml@5.2.1": "5.2.2",
|
||||
"qs@6.15.1": "6.15.2",
|
||||
"ws@8.18.3": "8.21.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+1662
-1630
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user