From 4e60c42bc2ab73c18cb1e24212d0a2ac872c7713 Mon Sep 17 00:00:00 2001 From: Christopher-walsh22 <106549296+Christopher-walsh22@users.noreply.github.com> Date: Mon, 30 Oct 2023 08:49:47 -0700 Subject: [PATCH] BRS:224 (#252) * Added function to convert month numbers to names for variance export --- lambda/export-variance/invokable/index.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lambda/export-variance/invokable/index.js b/lambda/export-variance/invokable/index.js index 89f5e1c..7eb02bb 100644 --- a/lambda/export-variance/invokable/index.js +++ b/lambda/export-variance/invokable/index.js @@ -236,12 +236,11 @@ function formatRecords(records) { } const date = record.pk.split('::')[2]; record['year'] = date.slice(0, 4); - record['month'] = date.slice(4); + record['month'] = convertMonth(parseInt(date.slice(4))); record['resolved'] = record.resolved ? 'YES' : 'NO'; if (/\r\n|\n|\r/.test(record.notes)) { record.notes = record.notes.replace(/(\r\n|\n|\r)/g, ' '); } - } } @@ -288,4 +287,19 @@ async function uploadToS3(csvData) { } logger.debug("Uploaded to S3"); +} + +function convertMonth(monthNumber){ + + const months = [ + 'January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December' + ]; + + if (monthNumber >= 1 && monthNumber <= 12) { + return months[monthNumber - 1]; + } else { + return 'Invalid month number'; + } + } \ No newline at end of file