core: cli: problemexport: auto add default pid

pull/564/head
undefined 1 year ago
parent cc9ed16f6c
commit 778cdf51cf
No known key found for this signature in database

@ -482,12 +482,12 @@ export class ProblemModel {
await fs.mkdir(tmpdir); await fs.mkdir(tmpdir);
const pdocs = await ProblemModel.getMulti(domainId, {}, ProblemModel.PROJECTION_PUBLIC).toArray(); const pdocs = await ProblemModel.getMulti(domainId, {}, ProblemModel.PROJECTION_PUBLIC).toArray();
for (const pdoc of pdocs) { for (const pdoc of pdocs) {
if (process.env.HYDRO_CLI) logger.info(`Exporting problem ${pdoc.pid} (${pdoc.title})`); if (process.env.HYDRO_CLI) logger.info(`Exporting problem ${pdoc.pid || (`P${pdoc.docId}`)} (${pdoc.title})`);
const problemPath = path.join(tmpdir, `${pdoc.docId}`); const problemPath = path.join(tmpdir, `${pdoc.docId}`);
await fs.mkdir(problemPath); await fs.mkdir(problemPath);
const problemYaml = path.join(problemPath, 'problem.yaml'); const problemYaml = path.join(problemPath, 'problem.yaml');
const problemYamlContent = yaml.dump({ const problemYamlContent = yaml.dump({
pid: pdoc.pid, pid: pdoc.pid || `P${pdoc.docId}`,
owner: pdoc.owner, owner: pdoc.owner,
title: pdoc.title, title: pdoc.title,
tag: pdoc.tag, tag: pdoc.tag,

Loading…
Cancel
Save