MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / edit

Method edit

packages/hydrooj/src/model/problem.ts:236–250  ·  view source on GitHub ↗
(domainId: string, _id: number, $set: Partial<ProblemDoc>)

Source from the content-addressed store, hash-verified

234 }
235
236 static async edit(domainId: string, _id: number, $set: Partial<ProblemDoc>): Promise<ProblemDoc> {
237 const delpid = $set.pid === '';
238 const ddoc = await DomainModel.get(domainId);
239 const $unset = delpid ? { pid: '' } : {};
240 if (delpid) {
241 delete $set.pid;
242 $set.sort = sortable(`P${_id}`, ddoc.namespaces);
243 } else if ($set.pid) {
244 $set.sort = sortable($set.pid, ddoc.namespaces);
245 }
246 await bus.parallel('problem/before-edit', $set, $unset);
247 const result = await document.set(domainId, document.TYPE_PROBLEM, _id, $set, $unset);
248 await bus.emit('problem/edit', result);
249 return result;
250 }
251
252 static async copy(domainId: string, _id: number, target: string, pid?: string, hidden?: boolean) {
253 const original = await ProblemModel.get(domainId, _id);

Callers 2

importMethod · 0.45
applyFunction · 0.45

Calls 3

sortableFunction · 0.70
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected