mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 17:46:28 +08:00
core: typing for tsdoc (#1164)
This commit is contained in:
1 parent
fbf27379b3
commit
a6cdbb9914
11 files changed
+108
-44
No files matched your search
@@ -5,7 +5,7 @@ import type fs from 'fs';
|
||||
import type { Dictionary, NumericDictionary } from 'lodash';
|
||||
import type { Binary, FindCursor, ObjectId } from 'mongodb';
|
||||
import type {
|
||||
FileInfo, RecordJudgeInfo, RecordPayload,
|
||||
FileInfo, RecordJudgeInfo, RecordPayload, SubtaskResult,
|
||||
} from '@hydrooj/common/types';
|
||||
import type { Context } from './context';
|
||||
import type { PrintTaskStatus } from './model/contest';
|
||||
@@ -412,11 +412,70 @@ export interface OplogDoc extends Record<string, any> {
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface ContestJournalEntry extends Record<string, any> {
|
||||
rid: ObjectId;
|
||||
pid: number;
|
||||
score: number;
|
||||
status: number;
|
||||
time?: number;
|
||||
lang?: string;
|
||||
subtasks?: Record<number, SubtaskResult>;
|
||||
}
|
||||
|
||||
export interface ContestDetailEntry extends Record<string, any> {
|
||||
rid?: ObjectId;
|
||||
pid?: number;
|
||||
score?: number;
|
||||
status?: number;
|
||||
/** ACM: penalty + elapsed time (in seconds). */
|
||||
time?: number;
|
||||
/** ACM: elapsed time since contest begin (in seconds). */
|
||||
real?: number;
|
||||
/** ACM: accumulated penalty (in seconds). */
|
||||
penalty?: number;
|
||||
/** ACM: number of non-accepted submissions on this problem. */
|
||||
naccept?: number;
|
||||
/** Number of submissions hidden after the scoreboard is locked. */
|
||||
npending?: number;
|
||||
/** Ledo: number of effective attempts. */
|
||||
ntry?: number;
|
||||
/** Ledo / homework: score after rule-specific bonus or penalty. */
|
||||
penaltyScore?: number;
|
||||
subtasks?: Record<number, SubtaskResult>;
|
||||
}
|
||||
|
||||
export interface ContestStat extends Record<string, any> {
|
||||
detail: Record<number, Record<string, any>>;
|
||||
detail: Record<number, ContestDetailEntry>;
|
||||
display?: Record<number, ContestDetailEntry>;
|
||||
score?: number;
|
||||
originalScore?: number;
|
||||
accept?: number;
|
||||
time?: number;
|
||||
penaltyScore?: number;
|
||||
unrank?: boolean;
|
||||
}
|
||||
|
||||
export interface ContestStatusDoc extends StatusDocBase, ContestStat {
|
||||
docId: ObjectId;
|
||||
docType: document['TYPE_CONTEST'];
|
||||
attend?: number;
|
||||
subscribe?: number;
|
||||
journal?: ContestJournalEntry[];
|
||||
startAt?: Date;
|
||||
endAt?: Date; // 灵活时间模式的结束时间,或者是提前结束比赛的时间
|
||||
rev?: number;
|
||||
}
|
||||
|
||||
export interface TrainingStatusDoc extends StatusDocBase, Record<string, any> {
|
||||
docId: ObjectId;
|
||||
docType: document['TYPE_TRAINING'];
|
||||
enroll?: number;
|
||||
attend?: number;
|
||||
doneNids?: number[];
|
||||
donePids?: number[];
|
||||
done?: boolean;
|
||||
}
|
||||
|
||||
export interface ScoreboardConfig {
|
||||
isExport: boolean;
|
||||
showDisplayName: boolean;
|
||||
@@ -436,21 +495,21 @@ export interface ContestRule<T = any> {
|
||||
showScoreboard: (tdoc: Tdoc, now: Date) => boolean;
|
||||
showSelfRecord: (tdoc: Tdoc, now: Date) => boolean;
|
||||
showRecord: (tdoc: Tdoc, now: Date) => boolean;
|
||||
stat: (this: ContestRule<T>, tdoc: Tdoc, journal: any[]) => ContestStat & T;
|
||||
stat: (this: ContestRule<T>, tdoc: Tdoc, journal: ContestJournalEntry[]) => ContestStat & T;
|
||||
scoreboardHeader: (
|
||||
this: ContestRule<T>, config: ScoreboardConfig, _: (s: string) => string,
|
||||
tdoc: Tdoc, pdict: ProblemDict,
|
||||
) => Promise<ScoreboardRow>;
|
||||
scoreboardRow: (
|
||||
this: ContestRule<T>, config: ScoreboardConfig, _: (s: string) => string,
|
||||
tdoc: Tdoc, pdict: ProblemDict, udoc: BaseUser, rank: number, tsdoc: ContestStat & T,
|
||||
tdoc: Tdoc, pdict: ProblemDict, udoc: BaseUser, rank: number, tsdoc: ContestStatusDoc & T,
|
||||
meta?: any,
|
||||
) => Promise<ScoreboardRow>;
|
||||
scoreboard: (
|
||||
this: ContestRule<T>, config: ScoreboardConfig, _: (s: string) => string,
|
||||
tdoc: Tdoc, pdict: ProblemDict, cursor: FindCursor<ContestStat & T>,
|
||||
tdoc: Tdoc, pdict: ProblemDict, cursor: FindCursor<ContestStatusDoc & T>,
|
||||
) => Promise<[board: ScoreboardRow[], udict: BaseUserDict]>;
|
||||
ranked: (tdoc: Tdoc, cursor: FindCursor<ContestStat & T>) => Promise<[number, ContestStat & T][]>;
|
||||
ranked: (tdoc: Tdoc, cursor: FindCursor<ContestStatusDoc & T>) => Promise<[number, ContestStatusDoc & T][]>;
|
||||
applyProjection: (tdoc: Tdoc, rdoc: RecordDoc, user: User) => RecordDoc;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user