From 8396ad9ebf63fe0b3b16644c9156abc68274c2fa Mon Sep 17 00:00:00 2001 From: Aidan Jones Date: Tue, 28 May 2024 09:15:14 -0400 Subject: [PATCH 1/2] Return dummy docSet object for catalog If catalog query fails, it most likely means there are no traditional books in the queried docSet. Adding a dummy docSet with the appropriate docSetID, language code, and book collection ID, still allows for a catalog entry to be created such that quizzes can still be added. --- convert/convertBooks.ts | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/convert/convertBooks.ts b/convert/convertBooks.ts index 9b016a5f1..324b8a612 100644 --- a/convert/convertBooks.ts +++ b/convert/convertBooks.ts @@ -227,7 +227,43 @@ export async function convertBooks( const frozen = freeze(pk); freezer.set(context.docSet, frozen[context.docSet]); //start catalog generation process - catalogEntries.push(pk.gqlQuery(queries.catalogQuery({ cv: true }))); + catalogEntries.push( + pk.gqlQuery(queries.catalogQuery({ cv: true })).then((j) => { + if (j.data.nDocSets > 0) { + return j; + } else { + if (verbose) { + console.log(` -- Empty DocSet: ${context.docSet}`); + } + // return empty version of appropriate docSet, + // as the query failed due to lack of documents. + return { + data: { + nDocSets: 1, + nDocuments: 0, + docSets: [ + { + id: context.docSet, + tagsKv: [], + selectors: [ + { + key: 'lang', + value: context.lang + }, + { + key: 'abbr', + value: context.bcId + } + ], + hasMapping: false, + documents: [] + } + ] + } + }; + } + }) + ); //check if folder exists for collection const collPath = path.join('static', 'collections', context.bcId); From 9344904a44f6a811d2f88e7da7aca713c6bfda62 Mon Sep 17 00:00:00 2001 From: Aidan Jones Date: Tue, 28 May 2024 09:31:29 -0400 Subject: [PATCH 2/2] Don't write pkf file if there is no docSet If a book collection does not have any traditional books, Proskomma will not have a docSet to write to a pkf file. THIS CHANGE WILL BREAK SEVERAL THINGS --- convert/convertBooks.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/convert/convertBooks.ts b/convert/convertBooks.ts index 324b8a612..dd62e0ab0 100644 --- a/convert/convertBooks.ts +++ b/convert/convertBooks.ts @@ -299,12 +299,15 @@ export async function convertBooks( //write frozen archives //push files to be written to files array - freezer.forEach((value, key) => - files.push({ - path: path.join('static', 'collections', key + '.pkf'), - content: value - }) - ); + freezer.forEach((value, key) => { + // don't write pkf if there is nothing to write + if (value) { + files.push({ + path: path.join('static', 'collections', key + '.pkf'), + content: value + }); + } + }); //write index file writeFileSync(