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

Function getFirst

packages/hydrooj/src/model/task.ts:17–33  ·  view source on GitHub ↗
(query: Filter<Task>)

Source from the content-addressed store, hash-verified

15const argv = cac().parse();
16
17async function getFirst(query: Filter<Task>) {
18 if (process.env.CI) return null;
19 try {
20 const q = { ...query };
21 const res = await coll.findOneAndDelete(q, { sort: { priority: -1 } });
22 if (res) {
23 logger.debug('%o', res);
24 return res;
25 }
26 return null;
27 } catch (e) {
28 // Usually caused by the database being down
29 // Should recover once it is back
30 logger.error(e);
31 return null;
32 }
33}
34
35export class Consumer {
36 consuming: boolean;

Callers 1

consumeMethod · 0.70

Calls 1

errorMethod · 0.45

Tested by

no test coverage detected