core: 添加contest.del与training.del方法

pull/61/head
undefined 4 years ago
parent 666a610b25
commit ea3a386b77

@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.20.28",
"version": "2.20.29",
"bin": "bin/hydrooj.js",
"main": "dist/loader.js",
"typings": "dist/loader.d.ts",

@ -385,6 +385,13 @@ export async function edit(
return await document.set(domainId, type, tid, $set);
}
export async function del(domainId: string, tid: ObjectID, type: Type = document.TYPE_CONTEST) {
await Promise.all([
document.deleteOne(domainId, type, tid),
document.deleteMultiStatus(domainId, type, { docId: tid }),
]);
}
export async function get(domainId: string, tid: ObjectID, type: -1): Promise<Tdoc<30 | 60>>;
export async function get<T extends Type>(domainId: string, tid: ObjectID, type: T): Promise<Tdoc<T>>;
export async function get(domainId: string, tid: ObjectID): Promise<Tdoc<30>>;
@ -601,6 +608,7 @@ global.Hydro.model.contest = {
getMultiStatus,
attend,
edit,
del,
get,
updateStatus,
getStatus,

@ -50,6 +50,13 @@ export function edit(domainId: string, tid: ObjectID, $set: Partial<TrainingDoc>
return document.set(domainId, document.TYPE_TRAINING, tid, $set);
}
export function del(domainId: string, tid: ObjectID) {
return Promise.all([
document.deleteOne(domainId, document.TYPE_TRAINING, tid),
document.deleteMultiStatus(domainId, document.TYPE_TRAINING, { docId: tid }),
]);
}
export function getPids(dag: TrainingNode[]) {
return Array.from(new Set(flatten(dag.map((node) => node.pids))));
}
@ -117,6 +124,7 @@ global.Hydro.model.training = {
isInvalid,
add,
edit,
del,
count,
get,
getList,

Loading…
Cancel
Save