Refactor object retrieval and template data handling in DocumentPrinterClient
All checks were successful
farmcontrol/farmcontrol-server/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-server/pipeline/head This commit looks good
- Updated the object retrieval logic to support multiple document objects, enhancing flexibility in handling document jobs. - Introduced a new `templateData` structure to consolidate retrieved objects, improving the deployment process in the `deploy` method. - Enhanced error handling and data management during the document printing workflow, ensuring more robust operations.
This commit is contained in:
parent
c6a4ba900e
commit
47751367b8
@ -605,10 +605,24 @@ export class DocumentPrinterClient {
|
||||
type: "deploying",
|
||||
progress: fetchTemplateProgress,
|
||||
});
|
||||
const objectRefs =
|
||||
Array.isArray(documentJob.objects) && documentJob.objects.length
|
||||
? documentJob.objects
|
||||
: documentJob.object != null
|
||||
? [documentJob.object]
|
||||
: [];
|
||||
const objects = [];
|
||||
for (const ref of objectRefs) {
|
||||
const object = await this.socketClient.getObject({
|
||||
objectType: documentJob.objectType,
|
||||
_id: documentJob.object._id,
|
||||
_id: ref?._id ?? ref,
|
||||
});
|
||||
objects.push(object);
|
||||
}
|
||||
const templateData =
|
||||
objects.length && objects[0] && typeof objects[0] === "object"
|
||||
? { ...objects[0], objects }
|
||||
: { objects };
|
||||
await this.updateJobState(documentJob._id, {
|
||||
type: "deploying",
|
||||
progress: fetchObjectProgress,
|
||||
@ -626,7 +640,7 @@ export class DocumentPrinterClient {
|
||||
const result = await this.printerInterface.deploy(
|
||||
documentJob,
|
||||
documentTemplate,
|
||||
object,
|
||||
templateData,
|
||||
async ({ progress, message } = {}) => {
|
||||
const mapped =
|
||||
renderProgressStart +
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user