mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core&judge: support lang filter
This commit is contained in:
3 files changed
+6
-3
No files matched your search
@@ -183,9 +183,10 @@ export default class Hydro implements Session {
|
||||
Authorization: `Bearer ${this.config.cookie.split('sid=')[1].split(';')[0]}`,
|
||||
},
|
||||
});
|
||||
const config: { prio?: number, concurrency?: number } = {};
|
||||
const config: { prio?: number, concurrency?: number, lang?: string[] } = {};
|
||||
if (this.config.minPriority !== undefined) config.prio = this.config.minPriority;
|
||||
if (this.config.concurrency !== undefined) config.concurrency = this.config.concurrency;
|
||||
if (this.config.lang?.length) config.lang = this.config.lang;
|
||||
const content = Object.keys(config).length
|
||||
? JSON.stringify({ key: 'config', ...config })
|
||||
: '{"key":"ping"}';
|
||||
|
||||
@@ -294,8 +294,6 @@ class JudgeConnectionHandler extends ConnectionHandler {
|
||||
await updateJudge(msg.info);
|
||||
} else if (msg.key === 'prio' && typeof msg.prio === 'number') {
|
||||
this.query.priority = { $gt: msg.prio };
|
||||
} else if (msg.key === 'lang' && msg.lang instanceof Array && msg.lang.every((i) => typeof i === 'string')) {
|
||||
this.query.lang = { $in: msg.lang };
|
||||
} else if (msg.key === 'config') {
|
||||
if (Number.isSafeInteger(msg.prio)) {
|
||||
this.query.priority = { $gt: msg.prio };
|
||||
@@ -309,6 +307,9 @@ class JudgeConnectionHandler extends ConnectionHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (msg.lang instanceof Array && msg.lang.every((i) => typeof i === 'string')) {
|
||||
this.query.lang = { $in: msg.lang };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ export default class RecordModel {
|
||||
else if (meta?.type === 'generate') type = 'generate';
|
||||
return await task.addMany(rids.map((rid) => ({
|
||||
...(pdoc.config as any),
|
||||
lang: rdoc.lang,
|
||||
priority,
|
||||
type,
|
||||
rid,
|
||||
|
||||
Reference in new issue
Block a user