Skip to content

Commit

Permalink
update missing export for no data (#376)
Browse files Browse the repository at this point in the history
Signed-off-by: David <[email protected]>
  • Loading branch information
davidclaveau authored Oct 4, 2024
1 parent 838720d commit ac6edc2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions arSam/handlers/export-missing/invokable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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';
Expand Down
1 change: 1 addition & 0 deletions arSam/layers/constantsLayer/constantsLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const STATE_DICTIONARY = {

VARIANCE_STATE_DICTIONARY = {
ERROR: 99,
NODATA: 0,
FETCHING: 1,
FORMATTING: 2,
GENERATING: 3,
Expand Down

0 comments on commit ac6edc2

Please sign in to comment.