core: contest: detail fix

This commit is contained in:
undefined committed 2021-10-26 15:00:07 +08:00
1 parent 7e8a90a6b2
commit a988445597
10 files changed
+10 -31

No files matched your search

-1
View File
@@ -123,7 +123,6 @@ export async function del(fileId: string) {
export async function run(execute, params?) { export async function run(execute, params?) {
let result; let result;
// eslint-disable-next-line no-return-await
if (typeof execute === 'object') return await runMultiple(execute); if (typeof execute === 'object') return await runMultiple(execute);
try { try {
if (!supportOptional) { if (!supportOptional) {
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "3.1.5", "version": "3.1.6",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "src/loader", "main": "src/loader",
"module": "src/loader", "module": "src/loader",
-1
View File
@@ -38,7 +38,6 @@ async function _parseDagJson(domainId: string, _dag: string): Promise<Tdoc['dag'
node.pids[i] = pdoc.docId; node.pids[i] = pdoc.docId;
})); }));
} }
// FIXME no-await-in-loop
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
await Promise.all(tasks); await Promise.all(tasks);
const newNode = { const newNode = {
-1
View File
@@ -206,7 +206,6 @@ export async function addTailReply(
export function getTailReply( export function getTailReply(
domainId: string, drid: ObjectID, drrid: ObjectID, domainId: string, drid: ObjectID, drrid: ObjectID,
): Promise<[DiscussionReplyDoc, DiscussionTailReplyDoc] | [null, null]> { ): Promise<[DiscussionReplyDoc, DiscussionTailReplyDoc] | [null, null]> {
// @ts-ignore
return document.getSub(domainId, document.TYPE_DISCUSSION_REPLY, drid, 'reply', drrid); return document.getSub(domainId, document.TYPE_DISCUSSION_REPLY, drid, 'reply', drrid);
} }
+6 -15
View File
@@ -601,27 +601,18 @@ const scripts: UpgradeScript[] = [
doc.domainId, document.TYPE_CONTEST, { docId: doc.docId }, doc.domainId, document.TYPE_CONTEST, { docId: doc.docId },
).toArray(); ).toArray();
for (const ctdoc of ctdocs) { for (const ctdoc of ctdocs) {
const cmark = ctdoc.journal?.filter((i) => isStringPid(i.pid)).length if (!ctdoc.journal?.filter((i) => isStringPid(i.pid)).length) continue;
|| ctdoc.detail?.filter((i) => isStringPid(i.pid)).length; const $set = {
if (!cmark) continue; journal: await Promise.all(ctdoc.journal.map(async (i) => {
const $set: any = {};
if (ctdoc.journal?.filter((i) => isStringPid(i.pid)).length) {
$set.journal = await Promise.all(ctdoc.journal.map(async (i) => {
const pdoc = await getProblem(doc.domainId, i.pid); const pdoc = await getProblem(doc.domainId, i.pid);
if (pdoc) i.pid = pdoc.docId; if (pdoc) i.pid = pdoc.docId;
return i; return i;
})); })),
} };
if (ctdoc.detail?.filter((i) => isStringPid(i.pid)).length) {
$set.detail = await Promise.all(ctdoc.detail.map(async (i) => {
const pdoc = await getProblem(doc.domainId, i.pid);
if (pdoc) i.pid = pdoc.docId;
return i;
}));
}
await document.setStatus(doc.domainId, doc.docType, doc.docId, ctdoc.uid, $set); await document.setStatus(doc.domainId, doc.docType, doc.docId, ctdoc.uid, $set);
} }
await contest.edit(doc.domainId, doc.docId, { pids }); await contest.edit(doc.domainId, doc.docId, { pids });
await contest.recalcStatus(doc.domainId, doc.docId);
} }
} }
await db.collection('record').updateMany({}, { $unset: { pdomain: '' } }); await db.collection('record').updateMany({}, { $unset: { pdomain: '' } });
-1
View File
@@ -8,7 +8,6 @@ export function buildProjection(fields: string[]): Record<string, 1> {
export const log2 = (val: bigint | number) => { export const log2 = (val: bigint | number) => {
if (typeof val === 'bigint') { if (typeof val === 'bigint') {
// @ts-ignore
for (let i = 0n; ; i++) if (!(val >> i)) return +i.toString() - 1; for (let i = 0n; ; i++) if (!(val >> i)) return +i.toString() - 1;
} else { } else {
for (let i = 0; ; i++) if (!(val >> i)) return i - 1; for (let i = 0; ; i++) if (!(val >> i)) return i - 1;
-1
View File
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-extraneous-dependencies
const path = require('path'); const path = require('path');
module.exports = { module.exports = {
-1
View File
@@ -91,7 +91,6 @@ class WikiHelpHandler extends Handler {
async get({ domainId }) { async get({ domainId }) {
const LANGS = setting.langs; const LANGS = setting.langs;
const languages = {}; const languages = {};
// eslint-disable-next-line guard-for-in
for (const key in LANGS) { for (const key in LANGS) {
if (LANGS[key].domain && !LANGS[key].domain.includes(domainId)) continue; if (LANGS[key].domain && !LANGS[key].domain.includes(domainId)) continue;
languages[`${LANGS[key].display}(${key})`] = LANGS[key].compile || LANGS[key].execute; languages[`${LANGS[key].display}(${key})`] = LANGS[key].compile || LANGS[key].execute;
-3
View File
@@ -47,7 +47,6 @@ async function load() {
...buildSequence(includedPages, 'after'), ...buildSequence(includedPages, 'after'),
...buildSequence(currentPage, 'after'), ...buildSequence(currentPage, 'after'),
]; ];
// eslint-disable-next-line no-restricted-syntax
for (const { page, func, type } of loadSequence) { for (const { page, func, type } of loadSequence) {
const ts = new Date().getTime(); const ts = new Date().getTime();
try { try {
@@ -69,13 +68,11 @@ async function load() {
$element: $(section), $element: $(section),
})); }));
console.log('done! %d ms', new Date().getTime() - start.getTime()); console.log('done! %d ms', new Date().getTime() - start.getTime());
// eslint-disable-next-line no-restricted-syntax
for (const { $element, shouldDelay } of sections) { for (const { $element, shouldDelay } of sections) {
$element.addClass('visible'); $element.addClass('visible');
if (shouldDelay) await delay(50); if (shouldDelay) await delay(50);
} }
await delay(500); await delay(500);
// eslint-disable-next-line no-restricted-syntax
for (const { $element } of sections) $element.trigger('vjLayout'); for (const { $element } of sections) $element.trigger('vjLayout');
$(document).trigger('vjPageFullyInitialized'); $(document).trigger('vjPageFullyInitialized');
} }
+3 -6
View File
@@ -130,12 +130,9 @@ Set.union = function Union<T>(setA: Set<T>, setB: Set<T>) {
return union; return union;
}; };
Set.intersection = function Intersection<T>(setA: Set<T>, setB: Set<T>): Set<T> { Set.intersection = function Intersection<T>(setA: Set<T>, setB: Set<T>) {
const intersection = new Set(); const intersection = new Set<T>();
for (const elem of setB) { for (const elem of setB) if (setA.has(elem)) intersection.add(elem);
if (setA.has(elem)) intersection.add(elem);
}
// @ts-ignore
return intersection; return intersection;
}; };