From d9919404b5b90151318d20258a273ca6c7640393 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Sat, 13 Mar 2021 13:59:34 +0100 Subject: [PATCH 1/3] Added logic for generateing multiple contracts per runner ref #35 --- src/PdfCreator.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/PdfCreator.ts b/src/PdfCreator.ts index 50023e1..31fbeb7 100644 --- a/src/PdfCreator.ts +++ b/src/PdfCreator.ts @@ -108,6 +108,11 @@ export class PdfCreator { if (runners.length == 1 && Object.keys(runners[0]).length == 0) { runners[0] = this.generateEmptyRunner(); } + for (var i = 1; i < PdfCreator.contractsPerRunner; i++) { + runners = runners.reduce(function (res, current, index, array) { + return res.concat([current, current]); + }, []); + } if (runners.length > 50) { let pdf_promises = new Array>(); let i, j; -- 2.47.2 From d01b4a0b99f3c1aa088b02d766d21bfb6b9e3a29 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Sat, 13 Mar 2021 14:01:30 +0100 Subject: [PATCH 2/3] Added config for amount of contracts per runner ref #35 --- src/PdfCreator.ts | 1 + src/config.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/PdfCreator.ts b/src/PdfCreator.ts index 31fbeb7..549cf4f 100644 --- a/src/PdfCreator.ts +++ b/src/PdfCreator.ts @@ -22,6 +22,7 @@ export class PdfCreator { private templateDir = path.join(__dirname, '/templates'); private browser; private static interpolations = { eventname: config.eventname, sponsoring_receipt_minimum_amount: config.sponsoring_receipt_minimum_amount, currency_symbol: config.currency_symbol } + private static contractsPerRunner = config.contracts_per_runner; /** * Main constructor. diff --git a/src/config.ts b/src/config.ts index d6e2565..7dbc3c0 100644 --- a/src/config.ts +++ b/src/config.ts @@ -13,11 +13,15 @@ export const config = { sponor_logos: getSponsorLogos(), api_key: getApiKey(), disclaimer_text: process.env.DISCLAIMER_TEXT || "", + contracts_per_runner: process.env.CONTRACTS_PER_RUNNER || 1, } let errors = 0 if (typeof config.internal_port !== "number") { errors++ } +if (typeof config.contracts_per_runner !== "number") { + errors++ +} if (typeof config.development !== "boolean") { errors++ } -- 2.47.2 From 31a59500fa77f1ad7c54fa297d00c8707ae6db9c Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Sat, 13 Mar 2021 14:03:14 +0100 Subject: [PATCH 3/3] Documented the new config var ref #35 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3773b94..d3bd447 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ The basic generation mechanism makes the templates and routes interchangeable (i | SPONOR_LOGOS | Array | Empty png | The sponsor images you want to loop through. You can provide them via http url, local file or base64-encoded image. | API_KEY | String(min length: 64) | Random generated string | The api key you want to use for auth (query-param `key`), has to be at least 64 chars long. | DISCLAIMER_TEXT | String | N/A | A disclaimer that will get displayed on the bottom of each sponsoring contract. R/N You can only provide the disclaimer for one language. +| CONTRACTS_PER_RUNNER | Number | 1 | The amount of contracts that get created per runner (per request). ## Templates > The document server uses html templates to generate various pdf documents. -- 2.47.2