优化结构

This commit is contained in:
undefined committed 2020-04-30 18:07:35 +08:00
1 parent 75ebc1a746
commit 2554cf660a
34 files changed
+401 -150

No files matched your search

+7 -2
View File
@@ -51,7 +51,11 @@ async function edit(tid, $set) {
if ($set.title) validator.checkTitle($set.title);
if ($set.content) validator.checkIntro($set.content);
if ($set.rule) { if (!this.RULES[$set.rule]) throw new ValidationError('rule'); }
if ($set.beginAt && $set.endAt) if ($set.beginAt >= $set.endAt) throw new ValidationError('beginAt', 'endAt');
if ($set.beginAt && $set.endAt) {
if ($set.beginAt >= $set.endAt) {
throw new ValidationError('beginAt', 'endAt');
}
}
const tdoc = await coll.findOne({ tid });
if (!tdoc) throw new ContestNotFoundError(tid);
this.RULES[$set.rule || tdoc.rule].check(Object.assign(tdoc, $set));
@@ -84,7 +88,8 @@ function getStatus(tid, uid) {
}
async function getListStatus(uid, tids) {
const r = {};
for (const tid of tids) r[tid] = await getStatus(tid, uid); // eslint-disable-line no-await-in-loop
// eslint-disable-next-line no-await-in-loop
for (const tid of tids) r[tid] = await getStatus(tid, uid);
return r;
}
async function attend(tid, uid) {