From 4e8cb19f55c26b02d78956b5c4fe771a1d6cc7b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Sun, 21 Mar 2021 23:13:56 +0000 Subject: [PATCH] Add runId in the results --- bin/lambda.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/lambda.js b/bin/lambda.js index d4b622b..20f58e2 100644 --- a/bin/lambda.js +++ b/bin/lambda.js @@ -5,11 +5,18 @@ const ylt = require('..'); // noinspection JSUnusedLocalSymbols async function runner({id, url, options = {}}, context) { console.log(`Processing run #${id} on ${url}`); + const bucket = process.env.RESULT_BUCKET_NAME; const keyPrefix = `results/${id}`; + const saveFile = async (path, content) => s3.putObject({Bucket: bucket, Key: `${keyPrefix}/${path}`, Body: content}) .promise(); - await saveFile('results.json', JSON.stringify(await ylt(url, {...options, saveFile}))); + + const results = JSON.stringify(await ylt(url, {...options, saveFile})); + results.runId = id; + + await saveFile('results.json', results); + return {status: 'processed', id, bucket, keyPrefix}; }