mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
workspace: update eslint rule (#1027)
This commit is contained in:
1 parent
05c3b8f2bd
commit
cee3c00ddb
150 files changed
+1069
-1043
No files matched your search
@@ -1,4 +1,4 @@
|
||||
/* eslint-disable no-tabs */
|
||||
/* eslint-disable style/no-tabs */
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import path from 'path';
|
||||
import mariadb from 'mariadb';
|
||||
@@ -70,7 +70,7 @@ export async function run({
|
||||
host = 'localhost', port = 3306, name = 'jol',
|
||||
username, password, domainId, contestType = 'oi',
|
||||
dataDir, uploadDir = '/home/judge/src/web/upload/', rerun = true, randomMail = false,
|
||||
}, report: Function) {
|
||||
}, report: (data: any) => void) {
|
||||
let remoteUsed = false;
|
||||
const src = await mariadb.createConnection({
|
||||
host,
|
||||
@@ -191,7 +191,7 @@ export async function run({
|
||||
samples: [[pdoc.sample_input.trim(), pdoc.sample_output.trim()]],
|
||||
hint: pdoc.hint,
|
||||
source: pdoc.source,
|
||||
}, 'html').replace(/<math xm<x>lns=/g, '<math xmlns=').replace(/\[\/?md]/g, '');
|
||||
}, 'html').replace(/<math xm<x>lns=/g, '<math xmlns=').replace(/\[\/?md\]/g, '');
|
||||
const uploadFiles = content.matchAll(/(?:src|href)="\/upload\/([^"/]+)(?:\/([^"/]+))?\/([^"/]+\.[^"/.]+)"/g);
|
||||
for (const file of uploadFiles) {
|
||||
try {
|
||||
@@ -295,7 +295,7 @@ hydrooj install https://hydro.ac/hydroac-client.zip
|
||||
await Promise.all(Object.keys(files).map((filename) => addContestFile(domainId, tid, filename, files[filename])));
|
||||
if (Object.keys(files).length) report({ message: `move ${Object.keys(files).length} file for contest ${tidMap[tdoc.contest_id]}` });
|
||||
|
||||
const allowedUser:{ user_id:string }[] = await query(`SELECT * FROM privilege WHERE rightstr = 'c${tdoc.contest_id}';`);
|
||||
const allowedUser: { user_id: string }[] = await query(`SELECT * FROM privilege WHERE rightstr = 'c${tdoc.contest_id}';`);
|
||||
const assignUserList = allowedUser.map((i) => uidMap[i.user_id]).filter((i) => i);
|
||||
if (isAssignMode) {
|
||||
await ContestModel.edit(domainId, tid, {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* eslint-disable no-tabs */
|
||||
/* eslint-disable no-await-in-loop */
|
||||
/* eslint-disable style/no-tabs */
|
||||
|
||||
import path from 'path';
|
||||
import zlib from 'zlib';
|
||||
import mariadb from 'mariadb';
|
||||
@@ -34,7 +35,7 @@ export async function run({
|
||||
host = 'localhost', port = 3306, name,
|
||||
username, password, domainId, contestType = 'oi',
|
||||
dataDir, imageDir, rerun = true, randomMail = false,
|
||||
}, report: Function) {
|
||||
}, report: (data: any) => void) {
|
||||
const src = await mariadb.createConnection({
|
||||
host,
|
||||
port,
|
||||
@@ -150,6 +151,7 @@ export async function run({
|
||||
hint: pdoc.hint,
|
||||
source: pdoc.source,
|
||||
}, 'html');
|
||||
// eslint-disable-next-line regexp/no-super-linear-backtracking
|
||||
const uploadFiles = content.matchAll(/(?:src|href)="\/images\/([^"]+\/([^"]+))"/g);
|
||||
for (const file of uploadFiles) {
|
||||
try {
|
||||
|
||||
@@ -75,7 +75,7 @@ export async function run({
|
||||
host = 'localhost', port = 3306, name = 'syzoj',
|
||||
username, password, domainId, dataDir,
|
||||
rerun = true, randomMail = 'never',
|
||||
}, report: Function) {
|
||||
}, report: (data: any) => void) {
|
||||
const src = await mariadb.createConnection({
|
||||
host,
|
||||
port,
|
||||
@@ -199,7 +199,7 @@ export async function run({
|
||||
`publicize_time` datetime NULL DEFAULT NULL, 公开时间
|
||||
`type` enum('traditional','submit-answer','interaction') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT 'traditional',
|
||||
*/
|
||||
const fileReg = /\[.*\]\((\/problem\/(\d+)\/testdata\/download\/(.*))\)/gm;
|
||||
const fileReg = /\[.*\]\((\/problem\/(\d+)\/testdata\/download\/(.*))\)/g;
|
||||
const pidMap: Record<string, number> = {};
|
||||
const configMap: Record<string, string> = {};
|
||||
const problemAdditionalFile = {};
|
||||
|
||||
@@ -45,7 +45,7 @@ export async function run({
|
||||
host = '172.17.0.2', port = 3306, name = 'app_uoj233',
|
||||
username, password, domainId, dataDir,
|
||||
rerun = true, randomMail = false,
|
||||
}, report: Function) {
|
||||
}, report: (data: any) => void) {
|
||||
const src = await mariadb.createConnection({
|
||||
host,
|
||||
port,
|
||||
@@ -506,10 +506,10 @@ export async function run({
|
||||
if (confInfo.n_subtasks
|
||||
&& Object.keys(confInfo.subtask_end).length === +confInfo.n_subtasks
|
||||
&& Object.keys(confInfo.subtask_score).length === +confInfo.n_subtasks) {
|
||||
config.subtasks.push(...[...new Array(+confInfo.n_subtasks)].map((v, i) => i + 1).map((i) => ({
|
||||
config.subtasks.push(...[...Array.from({ length: +confInfo.n_subtasks })].map((v, i) => i + 1).map((i) => ({
|
||||
id: +i,
|
||||
score: confInfo.subtask_score[i],
|
||||
cases: [...new Array(confInfo.subtask_end[i] - (confInfo.subtask_end[i - 1] || 0))].map((v, j) => ({
|
||||
cases: [...Array.from({ length: confInfo.subtask_end[i] - (confInfo.subtask_end[i - 1] || 0) })].map((v, j) => ({
|
||||
input: `${confInfo.input_pre}${j + (confInfo.subtask_end[i - 1] || 0) + 1}.${confInfo.input_suf}`,
|
||||
output: `${confInfo.output_pre}${j + (confInfo.subtask_end[i - 1] || 0) + 1}.${confInfo.output_suf}`,
|
||||
})),
|
||||
@@ -521,7 +521,7 @@ export async function run({
|
||||
id: 1,
|
||||
score: 97,
|
||||
type: 'sum' as SubtaskType,
|
||||
cases: [...new Array(+confInfo.n_tests)].map((v, i) => i + 1).map((i) => ({
|
||||
cases: [...Array.from({ length: +confInfo.n_tests })].map((v, i) => i + 1).map((i) => ({
|
||||
input: `${confInfo.input_pre}${i}.${confInfo.input_suf}`,
|
||||
output: `${confInfo.output_pre}${i}.${confInfo.output_suf}`,
|
||||
})),
|
||||
@@ -530,7 +530,7 @@ export async function run({
|
||||
config.subtasks.push({
|
||||
id: Math.max(...config.subtasks.map((i) => i.id)) + 1,
|
||||
score: 3,
|
||||
cases: [...new Array(+confInfo.n_ex_tests)].map((v, i) => i + 1).map((i) => ({
|
||||
cases: [...Array.from({ length: +confInfo.n_ex_tests })].map((v, i) => i + 1).map((i) => ({
|
||||
input: `ex_${confInfo.input_pre}${i}.${confInfo.input_suf}`,
|
||||
output: `ex_${confInfo.output_pre}${i}.${confInfo.output_suf}`,
|
||||
})),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
/* eslint-disable ts/naming-convention */
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import mongodb, { Db, FindCursor } from 'mongodb';
|
||||
import {
|
||||
@@ -13,6 +13,8 @@ const pid = (id) => {
|
||||
return id;
|
||||
};
|
||||
|
||||
type Report = (args: { progress?: number, message?: string }) => void;
|
||||
|
||||
const tasks = {
|
||||
user: async (doc) => ({
|
||||
_id: doc._id,
|
||||
@@ -93,7 +95,7 @@ const tasks = {
|
||||
processer: (rule) => {
|
||||
const n = {};
|
||||
for (const key in rule) {
|
||||
n[parseInt(key, 10) / 3600] = rule;
|
||||
n[Number.parseInt(key, 10) / 3600] = rule;
|
||||
}
|
||||
return n;
|
||||
},
|
||||
@@ -282,7 +284,7 @@ const cursor: NodeJS.Dict<CursorGetter> = {
|
||||
file: (s) => s.collection('fs.files').find(),
|
||||
};
|
||||
|
||||
async function discussionNode(src: Db, report: Function) {
|
||||
async function discussionNode(src: Db, report: Report) {
|
||||
const count = await src.collection('document').countDocuments({ doc_type: 20 });
|
||||
await report({ progress: 1, message: `discussion.node: ${count}` });
|
||||
const total = Math.floor(count / 5);
|
||||
@@ -327,7 +329,7 @@ async function fix(doc) {
|
||||
);
|
||||
}
|
||||
|
||||
async function fixProblem(report: Function) {
|
||||
async function fixProblem(report: Report) {
|
||||
const count = await dst.collection('document').countDocuments({ docType: 10 });
|
||||
await report({ progress: 1, message: `Fix pid: ${count}` });
|
||||
const total = Math.floor(count / 50);
|
||||
@@ -349,7 +351,7 @@ function objid(ts: Date) {
|
||||
}
|
||||
|
||||
// FIXME this seems not working
|
||||
async function message(src: Db, report: Function) {
|
||||
async function message(src: Db, report: Report) {
|
||||
const count = await src.collection('message').countDocuments();
|
||||
await report({ progress: 1, message: `Messages: ${count}` });
|
||||
const total = Math.floor(count / 50);
|
||||
@@ -373,7 +375,7 @@ async function message(src: Db, report: Function) {
|
||||
}
|
||||
}
|
||||
|
||||
async function removeInvalidPid(report: Function) {
|
||||
async function removeInvalidPid(report: Report) {
|
||||
const count = await dst.collection('document').countDocuments({ docType: 10 });
|
||||
const bulk = dst.collection('document').initializeUnorderedBulkOp();
|
||||
await report({ progress: 1, message: `Remove pid: ${count}` });
|
||||
@@ -383,7 +385,7 @@ async function removeInvalidPid(report: Function) {
|
||||
.find({ docType: 10 }).skip(i * 50).limit(50)
|
||||
.toArray();
|
||||
for (const doc of docs) {
|
||||
const id = parseInt(doc.pid, 10);
|
||||
const id = Number.parseInt(doc.pid, 10);
|
||||
if (Number.isSafeInteger(id)) {
|
||||
bulk.find({ _id: doc._id }).updateOne({ $unset: { pid: '' } });
|
||||
}
|
||||
@@ -392,7 +394,7 @@ async function removeInvalidPid(report: Function) {
|
||||
}
|
||||
}
|
||||
|
||||
async function task(name: any, src: Db, report: Function) {
|
||||
async function task(name: any, src: Db, report: Report) {
|
||||
await report({ progress: 1, message: `${name}` });
|
||||
let lastProgress = -1;
|
||||
for (let i = 0; ; i++) {
|
||||
@@ -466,7 +468,7 @@ async function task(name: any, src: Db, report: Function) {
|
||||
|
||||
export async function run({
|
||||
host = 'localhost', port = 27017, name = 'vijos4', username, password,
|
||||
}, report: Function) {
|
||||
}, report: Report) {
|
||||
let mongourl = 'mongodb://';
|
||||
if (username) mongourl += `${username}:${password}@`;
|
||||
mongourl += `${host}:${port}/${name}`;
|
||||
|
||||
Reference in new issue
Block a user