Skip to content

Commit

Permalink
core&judge: support lang filter
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined-moe committed Dec 15, 2023
1 parent d121a71 commit 928bd9f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/hydrojudge/src/hosts/hydro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"}';
Expand Down
5 changes: 3 additions & 2 deletions packages/hydrooj/src/handler/judge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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 };
}
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/hydrooj/src/model/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 928bd9f

Please sign in to comment.