initial commit
Some checks failed
release-tag / release-image (push) Failing after 1m14s

This commit is contained in:
konchin
2024-10-11 19:49:58 +08:00
commit 2d7361e937
38 changed files with 4029 additions and 0 deletions

18
models/contests.ts Normal file
View File

@@ -0,0 +1,18 @@
import {Schema, model, Types} from 'mongoose';
import {Problem} from './problems';
export interface Contest{
_id: Types.ObjectId;
channelId: string;
startTime: number;
problems: Problem[];
}
const contestSchema = new Schema<Contest>({
channelId: {type: String, required: true},
startTime: {type: Number, required: true},
problems: [{type: Schema.Types.ObjectId, ref: 'Problem'}],
});
export const contestModel = model<Contest>('Contest', contestSchema);

22
models/problems.ts Normal file
View File

@@ -0,0 +1,22 @@
import {Schema, model, Types} from 'mongoose';
import {Session} from './sessions';
export interface Problem{
_id: Types.ObjectId;
problemId: string;
read: Session[];
code: Session[];
wa: number[];
ac: number;
}
const problemSchema = new Schema<Problem>({
problemId: {type: String, required: true},
read: {type: [{type: Schema.Types.ObjectId, ref: 'Session'}], default: []},
code: {type: [{type: Schema.Types.ObjectId, ref: 'Session'}], default: []},
wa: {type: [Number], default: []},
ac: {type: Number, default: -1},
});
export const problemModel = model<Problem>('Problem', problemSchema);

16
models/sessions.ts Normal file
View File

@@ -0,0 +1,16 @@
import {Schema, model, Types} from 'mongoose';
export interface Session{
_id: Types.ObjectId;
name: string;
start: number;
end: number;
}
const sessionSchema = new Schema<Session>({
name: {type: String, required: true},
start: {type: Number, required: true},
end: {type: Number, default: -1},
});
export const sessionModel = model<Session>('Session', sessionSchema);