Skip to content

Commit

Permalink
fix domjudge fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined-moe committed Jun 14, 2024
1 parent 936baf3 commit db89242
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const serverSchema = Schema.intersect([
Schema.const('domjudge'),
Schema.const('hydro'),
] as const).required(),
server: Schema.string().role('url').required(),
server: Schema.transform(String, (i) => (i.endsWith('/') ? i : `${i}/`)).role('url').required(),
contestId: Schema.string(),
token: Schema.string(),
username: Schema.string(),
Expand Down
10 changes: 5 additions & 5 deletions packages/server/service/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ class DOMjudgeFetcher extends BasicFetcher {
async contestInfo() {
let contest;
if (!config.contestId) {
const { body } = await fetch('/api/v4/contests?onlyActive=true');
const { body } = await fetch('./api/v4/contests?onlyActive=true');
if (!body || !body.length) {
logger.error('Contest not found');
return false;
}
contest = body[0];
} else {
const { body } = await fetch(`/api/v4/contests/${config.contestId}`);
const { body } = await fetch(`./api/v4/contests/${config.contestId}`);
if (!body || !body.id) {
logger.error(`Contest ${config.contestId} not found`);
return false;
Expand All @@ -88,7 +88,7 @@ class DOMjudgeFetcher extends BasicFetcher {
}

async teamInfo() {
const { body } = await fetch(`/api/v4/contests/${this.contest.id}/teams`);
const { body } = await fetch(`./api/v4/contests/${this.contest.id}/teams`);
if (!body || !body.length) return;
const teams = body;
for (const team of teams) {
Expand All @@ -99,7 +99,7 @@ class DOMjudgeFetcher extends BasicFetcher {

async balloonInfo(all) {
if (all) logger.info('Sync all balloons...');
const { body } = await fetch(`/api/v4/contests/${this.contest.id}/balloons?todo=${all ? 'false' : 'true'}`);
const { body } = await fetch(`./api/v4/contests/${this.contest.id}/balloons?todo=${all ? 'false' : 'true'}`);
if (!body || !body.length) return;
const balloons = body;
for (const balloon of balloons) {
Expand Down Expand Up @@ -136,7 +136,7 @@ class DOMjudgeFetcher extends BasicFetcher {
}

async setBalloonDone(bid) {
await fetch(`/api/v4/contests/${this.contest.id}/balloons/${bid}/done`, 'post');
await fetch(`./api/v4/contests/${this.contest.id}/balloons/${bid}/done`, 'post');
logger.debug(`Balloon ${bid} set done`);
}
}
Expand Down

0 comments on commit db89242

Please sign in to comment.