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
@@ -23,7 +23,7 @@ class RecordListHandler extends RecordHandler {
|
||||
if (uidOrName) {
|
||||
q.$or = [
|
||||
{ unameLower: uidOrName.toLowerCase() },
|
||||
{ _id: parseInt(uidOrName) },
|
||||
{ _id: parseInt(uidOrName, 10) },
|
||||
];
|
||||
}
|
||||
if (pid) q.pid = pid;
|
||||
|
||||
@@ -54,6 +54,7 @@ class SystemSettingHandler extends SystemHandler {
|
||||
const current = {};
|
||||
const settings = setting.SYSTEM_SETTINGS;
|
||||
for (const s of settings) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
current[s.key] = await system.get(s.key);
|
||||
}
|
||||
this.response.body = {
|
||||
|
||||
@@ -39,7 +39,7 @@ async function _parseDagJson(domainId, dag) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await Promise.all(tasks);
|
||||
const newNode = {
|
||||
_id: parseInt(node._id),
|
||||
_id: parseInt(node._id, 10),
|
||||
title: node.title,
|
||||
requireNids: Array.from(new Set(node.requireNids)),
|
||||
pids: Array.from(new Set(node.pids)),
|
||||
@@ -112,8 +112,9 @@ class TrainingDetailHandler extends TrainingHandler {
|
||||
for (const pid in psdict) {
|
||||
const psdoc = psdict[pid];
|
||||
if (psdoc.status) {
|
||||
if (psdoc.status === builtin.STATUS.STATUS_ACCEPTED) donePids.add(parseInt(pid));
|
||||
else progPids.add(parseInt(pid));
|
||||
if (psdoc.status === builtin.STATUS.STATUS_ACCEPTED) {
|
||||
donePids.add(parseInt(pid, 10));
|
||||
} else progPids.add(parseInt(pid, 10));
|
||||
}
|
||||
}
|
||||
const nsdict = {};
|
||||
@@ -124,7 +125,7 @@ class TrainingDetailHandler extends TrainingHandler {
|
||||
const totalCount = node.pids.length;
|
||||
const doneCount = Set.union(new Set(node.pids), donePids).size;
|
||||
const nsdoc = {
|
||||
progress: totalCount ? parseInt(100 * (doneCount / totalCount)) : 100,
|
||||
progress: totalCount ? parseInt(100 * (doneCount / totalCount), 10) : 100,
|
||||
isDone: training.isDone(node, doneNids, donePids),
|
||||
isProgress: training.isProgress(node, doneNids, donePids, progPids),
|
||||
isOpen: training.isOpen(node, doneNids, donePids, progPids),
|
||||
|
||||
@@ -156,7 +156,7 @@ class UserSearchHandler extends Handler {
|
||||
let udocs;
|
||||
if (exactMatch) udocs = [];
|
||||
else udocs = await user.getPrefixList(q, 20);
|
||||
const udoc = await user.getById(domainId, parseInt(q));
|
||||
const udoc = await user.getById(domainId, parseInt(q, 10));
|
||||
if (udoc) udocs.push(udoc);
|
||||
for (const i in udocs) {
|
||||
if (udocs[i].gravatar) {
|
||||
|
||||
Reference in new issue
Block a user