mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
优化丑陋的代码
This commit is contained in:
1 parent
62ac2f52c9
commit
dd1b7c363a
19 files changed
+97
-502
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user