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

Method get

packages/hydrooj/src/handler/problem.ts:835–866  ·  view source on GitHub ↗
(domainId: string, page = 1, tid?: ObjectId, sid?: ObjectId)

Source from the content-addressed store, hash-verified

833 @param('tid', Types.ObjectId, true)
834 @param('sid', Types.ObjectId, true)
835 async get(domainId: string, page = 1, tid?: ObjectId, sid?: ObjectId) {
836 if (tid) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_SOLUTION);
837 this.response.template = 'problem_solution.html';
838 const accepted = this.psdoc?.status === STATUS.STATUS_ACCEPTED;
839 if (!accepted || !this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_SOLUTION_ACCEPT)) {
840 this.checkPerm(PERM.PERM_VIEW_PROBLEM_SOLUTION);
841 }
842
843 let [psdocs, pcount, pscount] = await this.paginate(
844 solution.getMulti(domainId, this.pdoc.docId),
845 page,
846 'solution',
847 );
848 if (sid) {
849 psdocs = [await solution.get(domainId, sid)];
850 if (!psdocs[0]) throw new SolutionNotFoundError(domainId, sid);
851 }
852 const uids = [this.pdoc.owner];
853 const docids = [];
854 for (const psdoc of psdocs) {
855 docids.push(psdoc.docId);
856 uids.push(psdoc.owner);
857 if (psdoc.reply.length) {
858 for (const psrdoc of psdoc.reply) uids.push(psrdoc.owner);
859 }
860 }
861 const udict = await user.getList(domainId, uids);
862 const pssdict = await solution.getListStatus(domainId, docids, this.user._id);
863 this.response.body = {
864 psdocs, page, pcount, pscount, udict, pssdict, pdoc: this.pdoc, sid,
865 };
866 }
867
868 @param('content', Types.Content)
869 async postSubmit(domainId: string, content: string) {

Callers

nothing calls this directly

Calls 8

hasPermMethod · 0.80
checkPermMethod · 0.80
paginateMethod · 0.65
getMultiMethod · 0.45
getMethod · 0.45
pushMethod · 0.45
getListMethod · 0.45
getListStatusMethod · 0.45

Tested by

no test coverage detected