core: fix load priority

This commit is contained in:
undefined committed 2022-10-06 03:39:38 +08:00
1 parent c3afc0074c
commit c63d7c16c1
4 files changed
+16 -17

No files matched your search

+3 -2
View File
@@ -44,14 +44,15 @@ export async function apply(ctx: Context) {
await ctx.root.start();
require('../lib/index');
await lib(pending, fail, ctx);
await ctx.lifecycle.flush();
await setting(pending, fail, require('../model/setting'));
ctx.plugin(require('../service/monitor'));
await service(pending, fail, ctx);
await builtinModel(ctx);
await model(pending, fail, ctx);
await ctx.lifecycle.flush();
const modelSetting = require('../model/setting');
await setting(pending, fail, modelSetting);
const handlerDir = path.resolve(__dirname, '..', 'handler');
const handlers = await fs.readdir(handlerDir);
for (const h of handlers) {
+11 -13
View File
@@ -241,14 +241,13 @@ SystemSetting(
export const langs: Record<string, LangConfig> = {};
export async function apply(ctx: Context) {
logger.debug('Ensuring settings');
logger.info('Ensuring settings');
const system = global.Hydro.model.system;
for (const setting of SYSTEM_SETTINGS) {
if (setting.value) {
const current = await global.Hydro.service.db.collection('system').findOne({ _id: setting.key });
if (!current || current.value == null || current.value === '') {
await retry(system.set, setting.key, setting.value);
}
if (!setting.value) continue;
const current = await global.Hydro.service.db.collection('system').findOne({ _id: setting.key });
if (!current || current.value == null || current.value === '') {
await retry(system.set, setting.key, setting.value);
}
}
try {
@@ -259,13 +258,12 @@ export async function apply(ctx: Context) {
ServerLangSettingNode.range = range;
} catch (e) { /* Ignore */ }
ctx.on('system/setting', (args) => {
if (args.hydrooj?.langs) {
Object.assign(langs, parseLang(args.hydrooj.langs));
const range = {};
for (const key in langs) range[key] = langs[key].display;
LangSettingNode.range = range;
ServerLangSettingNode.range = range;
}
if (!args.hydrooj?.langs) return;
Object.assign(langs, parseLang(args.hydrooj.langs));
const range = {};
for (const key in langs) range[key] = langs[key].display;
LangSettingNode.range = range;
ServerLangSettingNode.range = range;
});
}
+1 -1
View File
@@ -64,7 +64,7 @@ export const RpTypes: Record<string, RpDef> = {
journal: { $ne: null },
}).sort(contest.RULES[tdoc.rule].statusSort);
if (!await cursor.count()) continue;
const [rankedTsdocs] = await contest.RULES[tdoc.rule].ranked(tdoc, cursor);
const rankedTsdocs = await contest.RULES[tdoc.rule].ranked(tdoc, cursor);
const users = rankedTsdocs.map((i) => ({ uid: i[1].uid, rank: i[0], old: udict[i[1].uid] }));
// FIXME sum(rating.new) always less than sum(rating.old)
for (const udoc of rating(users)) udict[udoc.uid] = udoc.new;
+1 -1
View File
@@ -401,7 +401,7 @@ const scripts: UpgradeScript[] = [
return true;
},
async function _59_60() {
const langs = await system.get('hydrooj.langs');
const langs = system.get('hydrooj.langs');
await system.set('hydrooj.langs', langs.replace(/\$\{dir\}/g, '/w').replace(/\$\{name\}/g, 'foo'));
return true;
},