Skip to content

Commit

Permalink
import-qduoj: fix source field
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined-moe committed Nov 24, 2024
1 parent 92499d4 commit eba7401
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/import-qduoj/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const tmpdir = path.join(os.tmpdir(), 'hydro', 'import-qduoj');
fs.ensureDirSync(tmpdir);

const StringValue = Schema.object({
format: Schema.union(['html', 'markdown']).default('html'),
value: Schema.string(),
});
const ProblemSchema = Schema.object({
Expand All @@ -23,7 +24,7 @@ const ProblemSchema = Schema.object({
output: Schema.string(),
})),
hint: StringValue,
source: StringValue,
source: Schema.union([StringValue, Schema.string()]),
display_id: Schema.string(),
time_limit: Schema.union([Schema.number(), Schema.string()]).required(),
memory_limit: Schema.union([Schema.number(), Schema.string()]).required(),
Expand Down Expand Up @@ -63,7 +64,7 @@ class ImportQduojHandler extends Handler {
output: pdoc.output_description?.value,
samples: pdoc.samples.map((sample) => [sample.input, sample.output]),
hint: pdoc.hint?.value,
source: pdoc.source?.value,
source: typeof pdoc.source === 'string' ? pdoc.source : pdoc.source?.value || '',
}, 'html');
if (+pdoc.display_id) pdoc.display_id = `P${pdoc.display_id}`;
const isValidPid = async (id: string) => {
Expand Down

0 comments on commit eba7401

Please sign in to comment.