mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
2.0.0(preview)
This commit is contained in:
1 parent
d5929d78b1
commit
1c8b62a6d9
33 files changed
+307
-241
No files matched your search
@@ -1,11 +1,22 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
const domain = require('../model/domain');
|
||||
const contest = require('../model/contest');
|
||||
const user = require('../model/user');
|
||||
const rating = require('../lib/rating');
|
||||
|
||||
async function run({ domainId }, report) {
|
||||
async function run({ domainId, isSub = false }, report) {
|
||||
if (!domainId) {
|
||||
const domains = await domain.getMulti().toArray();
|
||||
await report({ total: domains.length });
|
||||
for (const i in domains) {
|
||||
await run({ domainId: domains[i]._id, isSub: true }, report);
|
||||
await report({ current: parseInt(i) + 1 });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const contests = await contest.getMulti(domainId).sort('endAt', -1).toArray();
|
||||
await report({ total: contests.length });
|
||||
await user.setMultiInDomain(domainId, {}, { rating: 1500 });
|
||||
for (const i in contests) {
|
||||
const tdoc = contests[i];
|
||||
const tsdocs = await contest.getMultiStatus(domainId, { docId: tdoc.docId })
|
||||
@@ -22,8 +33,10 @@ async function run({ domainId }, report) {
|
||||
tasks.push(user.setInDomain(domainId, udoc.uid, { rating: udoc.new }));
|
||||
}
|
||||
await Promise.all(tasks);
|
||||
await report({ current: i + 1 });
|
||||
if (isSub) await report({ subProgress: (i + 1) / contests.length });
|
||||
else await report({ current: parseInt(i) + 1 });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
global.Hydro.script.recalcRating = module.exports = { run };
|
||||
Reference in new issue
Block a user