Skip to content

Commit

Permalink
BRS:224 (#252)
Browse files Browse the repository at this point in the history
* Added function to convert month numbers to names for variance export
  • Loading branch information
Christopher-walsh22 authored Oct 30, 2023
1 parent cba7e97 commit 4e60c42
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lambda/export-variance/invokable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, ' ');
}

}
}

Expand Down Expand Up @@ -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';
}

}

0 comments on commit 4e60c42

Please sign in to comment.