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?) {
let result;
// eslint-disable-next-line no-return-await
if (typeof execute === 'object') return await runMultiple(execute);
try {
if (!supportOptional) {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "3.1.5",
"version": "3.1.6",
"bin": "bin/hydrooj.js",
"main": "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;
}));
}
// FIXME no-await-in-loop
// eslint-disable-next-line no-await-in-loop
await Promise.all(tasks);
const newNode = {
-1
View File
@@ -206,7 +206,6 @@ export async function addTailReply(
export function getTailReply(
domainId: string, drid: ObjectID, drrid: ObjectID,
): Promise<[DiscussionReplyDoc, DiscussionTailReplyDoc] | [null, null]> {
// @ts-ignore
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 },
).toArray();
for (const ctdoc of ctdocs) {
const cmark = ctdoc.journal?.filter((i) => isStringPid(i.pid)).length
|| ctdoc.detail?.filter((i) => isStringPid(i.pid)).length;
if (!cmark) continue;
const $set: any = {};
if (ctdoc.journal?.filter((i) => isStringPid(i.pid)).length) {
$set.journal = await Promise.all(ctdoc.journal.map(async (i) => {
if (!ctdoc.journal?.filter((i) => isStringPid(i.pid)).length) continue;
const $set = {
journal: await Promise.all(ctdoc.journal.map(async (i) => {
const pdoc = await getProblem(doc.domainId, i.pid);
if (pdoc) i.pid = pdoc.docId;
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 contest.edit(doc.domainId, doc.docId, { pids });
await contest.recalcStatus(doc.domainId, doc.docId);
}
}
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) => {
if (typeof val === 'bigint') {
// @ts-ignore
for (let i = 0n; ; i++) if (!(val >> i)) return +i.toString() - 1;
} else {
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');
module.exports = {
-1
View File
@@ -91,7 +91,6 @@ class WikiHelpHandler extends Handler {
async get({ domainId }) {
const LANGS = setting.langs;
const languages = {};
// eslint-disable-next-line guard-for-in
for (const key in LANGS) {
if (LANGS[key].domain && !LANGS[key].domain.includes(domainId)) continue;
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(currentPage, 'after'),
];
// eslint-disable-next-line no-restricted-syntax
for (const { page, func, type } of loadSequence) {
const ts = new Date().getTime();
try {
@@ -69,13 +68,11 @@ async function load() {
$element: $(section),
}));
console.log('done! %d ms', new Date().getTime() - start.getTime());
// eslint-disable-next-line no-restricted-syntax
for (const { $element, shouldDelay } of sections) {
$element.addClass('visible');
if (shouldDelay) await delay(50);
}
await delay(500);
// eslint-disable-next-line no-restricted-syntax
for (const { $element } of sections) $element.trigger('vjLayout');
$(document).trigger('vjPageFullyInitialized');
}
+3 -6
View File
@@ -130,12 +130,9 @@ Set.union = function Union<T>(setA: Set<T>, setB: Set<T>) {
return union;
};
Set.intersection = function Intersection<T>(setA: Set<T>, setB: Set<T>): Set<T> {
const intersection = new Set();
for (const elem of setB) {
if (setA.has(elem)) intersection.add(elem);
}
// @ts-ignore
Set.intersection = function Intersection<T>(setA: Set<T>, setB: Set<T>) {
const intersection = new Set<T>();
for (const elem of setB) if (setA.has(elem)) intersection.add(elem);
return intersection;
};