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

Method random

packages/hydrooj/src/model/problem.ts:376–382  ·  view source on GitHub ↗
(domainId: string, query: Filter<ProblemDoc>)

Source from the content-addressed store, hash-verified

374 }
375
376 static async random(domainId: string, query: Filter<ProblemDoc>) {
377 const pcount = await document.count(domainId, document.TYPE_PROBLEM, query);
378 if (!pcount) return null;
379 const pdoc = await document.getMulti(domainId, document.TYPE_PROBLEM, query)
380 .skip(Math.floor(Math.random() * pcount)).limit(1).toArray();
381 return pdoc[0].pid || pdoc[0].docId;
382 }
383
384 static async getList(
385 domainId: string, pids: number[], canViewHidden: number | boolean = false,

Callers 15

service-worker.tsFile · 0.80
Marker.jsFile · 0.80
initMonacoMethod · 0.80
asMasterFunction · 0.80
initConnFunction · 0.80
mountComponentFunction · 0.80
escapeGroupNameFunction · 0.80
db.tsFile · 0.80
importMethod · 0.80
exportMethod · 0.80
getMethod · 0.80

Calls 2

countMethod · 0.45
getMultiMethod · 0.45

Tested by

no test coverage detected