add option to use xcpcio as default scoreboard

This commit is contained in:
undefined committed 2025-11-18 18:15:48 +08:00
1 parent 191353fbbc
commit 5810371934
2 files changed
+11 -7

No files matched your search

+11
View File
@@ -91,6 +91,7 @@ export const name = 'scoreboard-xcpcio';
export const Config = Schema.object({
cacheTTL: Schema.number().default(0).description('Cache TTL in milliseconds'),
cacheSize: Schema.number().default(100).description('Cache size'),
asDefault: Schema.boolean().default(false).description('As default scoreboard'),
});
export async function apply(ctx: Context, config: ReturnType<typeof Config>) {
@@ -126,6 +127,16 @@ export async function apply(ctx: Context, config: ReturnType<typeof Config>) {
});
}
if (config.asDefault) {
// eslint-disable-next-line consistent-return
ctx.on('handler/before/ContestScoreboard#get', (that) => {
if (that.request.path.endsWith('/scoreboard') && that.tdoc?.rule === 'acm') {
that.response.redirect = `${that.request.path}/xcpcio`;
return 'cleanup';
}
});
}
ctx.inject(['scoreboard'], ({ scoreboard }) => {
scoreboard.addView('xcpcio', 'XCPCIO', {
tdoc: 'tdoc',