feat: add competition persistence schemas

This commit is contained in:
dahyeon committed 2026-07-12 18:49:37 +00:00
1 parent 05a83db886
commit 2135af7107
3 files changed
+540

No files matched your search

@@ -3,6 +3,13 @@ import type {
RiotPlatformRoute,
RiotRegionalRoute,
} from '../../riot/riot.types';
import {
Competition,
CompetitionFact,
CompetitionOutbox,
TournamentCodeAssignment,
competitionModelDefinitions,
} from '../../competition/competition.schema';
import { ModelDefinition } from './types';
export type Position = 'TOP' | 'JGL' | 'MID' | 'ADC' | 'SUP';
@@ -672,6 +679,7 @@ export interface MatchScheduleItem {
export interface Match extends MongooseTimestamps {
communityId: mongoose.Types.ObjectId;
competitionId?: mongoose.Types.ObjectId;
shortCode?: string;
title: string;
description: string;
@@ -1021,6 +1029,9 @@ export interface MatchStatsTimelinePoint {
export interface MatchStats extends MongooseTimestamps {
matchId: mongoose.Types.ObjectId;
sourceCompetitionId?: mongoose.Types.ObjectId;
sourceRevision?: number;
projectorVersion?: number;
communityId: mongoose.Types.ObjectId;
scheduledAt: Date;
gameCreationMin: number;
@@ -1845,6 +1856,11 @@ export const MatchSchema = new Schema<Match>(
ref: 'community',
required: true,
},
competitionId: {
type: Schema.Types.ObjectId,
ref: 'competition',
required: false,
},
shortCode: {
type: String,
required: false,
@@ -1936,6 +1952,13 @@ export const MatchSchema = new Schema<Match>(
);
MatchSchema.index({ communityId: 1, scheduledAt: -1 });
MatchSchema.index(
{ competitionId: 1 },
{
unique: true,
partialFilterExpression: { competitionId: { $type: 'objectId' } },
},
);
MatchSchema.index({ communityId: 1, status: 1, scheduledAt: -1 });
MatchSchema.index(
{ communityId: 1, shortCode: 1 },
@@ -2389,6 +2412,13 @@ export const MatchStatsSchema: mongoose.Schema<MatchStats> = new Schema(
required: true,
unique: true,
},
sourceCompetitionId: {
type: Schema.Types.ObjectId,
ref: 'competition',
required: false,
},
sourceRevision: { type: Number, required: false, min: 0 },
projectorVersion: { type: Number, required: false, min: 1 },
communityId: {
type: Schema.Types.ObjectId,
ref: 'community',
@@ -2419,6 +2449,7 @@ MatchStatsSchema.index({ communityId: 1, userIds: 1, scheduledAt: -1 });
MatchStatsSchema.index({ communityId: 1, championIds: 1 });
export const tournamentModelDefinitions: ModelDefinition[] = [
...competitionModelDefinitions,
{ name: 'identity', schema: IdentitySchema, schemaName: 'identity' },
{ name: 'community', schema: CommunitySchema, schemaName: 'community' },
{
@@ -2468,6 +2499,10 @@ export const tournamentModelDefinitions: ModelDefinition[] = [
];
export interface TournamentModelTypes {
competition: Competition;
competitionFact: CompetitionFact;
competitionOutbox: CompetitionOutbox;
tournamentCodeAssignment: TournamentCodeAssignment;
identity: Identity;
community: Community;
dakaoInboundMessage: DakaoInboundMessage;