优化丑陋的代码

This commit is contained in:
undefined committed 2020-06-23 22:40:01 +08:00
1 parent 62ac2f52c9
commit dd1b7c363a
19 files changed
+97 -502

No files matched your search

+3 -3
View File
@@ -20,7 +20,7 @@ async function run({ domainId, isSub = false }, report) {
memory_kb: 0,
score: 0,
},
progress: Math.floor(((parseInt(i) + 1) / domains.length) * 100),
progress: Math.floor(((parseInt(i, 10) + 1) / domains.length) * 100),
});
}
return true;
@@ -44,7 +44,7 @@ async function run({ domainId, isSub = false }, report) {
udict[udoc.uid] = udoc.new;
}
if (!isSub) {
await report({ progress: Math.floor(((parseInt(i) + 1) / contests.length) * 100) });
await report({ progress: Math.floor(((parseInt(i, 10) + 1) / contests.length) * 100) });
}
await report({
case: {
@@ -58,7 +58,7 @@ async function run({ domainId, isSub = false }, report) {
}
const tasks = [];
for (const uid in udict) {
tasks.push(user.setInDomain(domainId, parseInt(uid), { rating: udict[uid] }));
tasks.push(user.setInDomain(domainId, parseInt(uid, 10), { rating: udict[uid] }));
}
await Promise.all(tasks);
return true;
+1 -1
View File
@@ -5,7 +5,7 @@ async function run({
uname, password, mail, uid,
}) {
if (!uid) uid = await system.inc('user');
else uid = parseInt(uid);
else uid = parseInt(uid, 10);
if (Number.isNaN(uid)) throw new Error('uid');
await user.create({
uid, uname, password, mail, regip: '127.0.0.1',
+1 -1
View File
@@ -3,7 +3,7 @@ const user = require('../model/user');
async function run({
uid,
}) {
uid = parseInt(uid);
uid = parseInt(uid, 10);
if (Number.isNaN(uid)) throw new Error('uid');
await user.setSuperAdmin(uid);
return uid;