diff --git a/arSam/handlers/export-missing/invokable/index.js b/arSam/handlers/export-missing/invokable/index.js index e8675f1..77bd22e 100644 --- a/arSam/handlers/export-missing/invokable/index.js +++ b/arSam/handlers/export-missing/invokable/index.js @@ -64,6 +64,12 @@ exports.handler = async (event, context) => { // collect missing records, use VARIANCE_STATE as it's the same const records = await getMissingRecords(fiscalYearEnd, roles, orcs); + + if (!records.length) { + await updateJobWithState(VARIANCE_STATE_DICTIONARY.NODATA); + return + } + await updateJobWithState(VARIANCE_STATE_DICTIONARY.FORMATTING); // format records for csv @@ -101,6 +107,14 @@ async function updateJobWithState(state, percentageOverride = null) { state = 'error'; message = 'Job failed. Exporter encountered an error.'; break; + + // no data, no report + case 0: + state = 'no_data'; + percentage = percentageOverride || 100; + message = 'No data - no report generated.'; + break; + // fetching data case 1: state = 'fetching_data'; diff --git a/arSam/layers/constantsLayer/constantsLayer.js b/arSam/layers/constantsLayer/constantsLayer.js index ea36cf1..5ca682b 100644 --- a/arSam/layers/constantsLayer/constantsLayer.js +++ b/arSam/layers/constantsLayer/constantsLayer.js @@ -94,6 +94,7 @@ const STATE_DICTIONARY = { VARIANCE_STATE_DICTIONARY = { ERROR: 99, + NODATA: 0, FETCHING: 1, FORMATTING: 2, GENERATING: 3,