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

This commit is contained in:
undefined committed 2021-03-25 02:02:06 +08:00
1 parent 666a610b25
commit ea3a386b77
3 files changed
+17 -1

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.20.28", "version": "2.20.29",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "dist/loader.js", "main": "dist/loader.js",
"typings": "dist/loader.d.ts", "typings": "dist/loader.d.ts",
+8
View File
@@ -385,6 +385,13 @@ export async function edit(
return await document.set(domainId, type, tid, $set); 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(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<T extends Type>(domainId: string, tid: ObjectID, type: T): Promise<Tdoc<T>>;
export async function get(domainId: string, tid: ObjectID): Promise<Tdoc<30>>; export async function get(domainId: string, tid: ObjectID): Promise<Tdoc<30>>;
@@ -601,6 +608,7 @@ global.Hydro.model.contest = {
getMultiStatus, getMultiStatus,
attend, attend,
edit, edit,
del,
get, get,
updateStatus, updateStatus,
getStatus, getStatus,
+8
View File
@@ -50,6 +50,13 @@ export function edit(domainId: string, tid: ObjectID, $set: Partial<TrainingDoc>
return document.set(domainId, document.TYPE_TRAINING, tid, $set); 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[]) { export function getPids(dag: TrainingNode[]) {
return Array.from(new Set(flatten(dag.map((node) => node.pids)))); return Array.from(new Set(flatten(dag.map((node) => node.pids))));
} }
@@ -117,6 +124,7 @@ global.Hydro.model.training = {
isInvalid, isInvalid,
add, add,
edit, edit,
del,
count, count,
get, get,
getList, getList,