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

Method get

packages/hydrooj/src/handler/problem.ts:281–292  ·  view source on GitHub ↗
(domainId: string, qs = '')

Source from the content-addressed store, hash-verified

279export class ProblemRandomHandler extends Handler {
280 @param('q', Types.Content, true)
281 async get(domainId: string, qs = '') {
282 const category = flattenDeep(qs.split(' ')
283 .filter((i) => i.startsWith('category:'))
284 .map((i) => i.split('category:')[1]?.split(',')));
285 const q = buildQuery(this.user);
286 if (category.length) q.$and = category.map((tag) => ({ tag }));
287 await this.ctx.parallel('problem/list', q, this);
288 const pid = await problem.random(domainId, q);
289 if (!pid) throw new NoProblemError();
290 this.response.body = { pid };
291 this.response.redirect = this.url('problem_detail', { pid });
292 }
293}
294
295export class ProblemDetailHandler extends ContestDetailBaseHandler {

Callers

nothing calls this directly

Calls 3

buildQueryFunction · 0.85
randomMethod · 0.80
urlMethod · 0.80

Tested by

no test coverage detected