Skip to content

Commit

Permalink
BRS-237 - Migration for Historical Data 2000-2016 (#389)
Browse files Browse the repository at this point in the history
* copy over migrate.js with small sdk update, small tweaks

* export won't scan past 2017, add purgeLegacy.js

---------

Signed-off-by: David <[email protected]>
  • Loading branch information
davidclaveau authored Dec 16, 2024
1 parent e191ceb commit eab1ac6
Show file tree
Hide file tree
Showing 6 changed files with 1,796 additions and 19 deletions.
29 changes: 11 additions & 18 deletions arSam/handlers/export/invokable/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
const fs = require("fs");
const writeXlsxFile = require("write-excel-file/node");
const {
TABLE_NAME,
getParks,
getSubAreas,
getRecords,
logger,
s3Client,
PutObjectCommand
} = require("/opt/baseLayer");
const {
EXPORT_NOTE_KEYS,
EXPORT_MONTHS,
CSV_SYSADMIN_SCHEMA,
STATE_DICTIONARY,
} = require("/opt/constantsLayer");
const { updateJobEntry } = require("/opt/functionsLayer");
const fs = require('fs');
const writeXlsxFile = require('write-excel-file/node');
const { DateTime } = require('luxon');
const { TABLE_NAME, getParks, getSubAreas, getRecords, logger, s3Client, PutObjectCommand } = require('/opt/baseLayer');
const { EXPORT_NOTE_KEYS, EXPORT_MONTHS, CSV_SYSADMIN_SCHEMA, STATE_DICTIONARY } = require('/opt/constantsLayer');
const { updateJobEntry } = require('/opt/functionsLayer');

const {
arraySum,
Expand Down Expand Up @@ -161,6 +149,11 @@ async function getAllRecords(roles = null, dateRangeStart = null, dateRangeEnd =
subareas = subareas.concat(parkSubAreas);
}
}
// Don't get records before 2017, all will be historical anyway
if (dateRangeStart == 'null' && dateRangeEnd == 'null') {
dateRangeStart = '2017-01';
dateRangeEnd = DateTime.now().setZone('America/Vancouver').toFormat('yyyyLL');
}
for (const subarea of subareas) {
const subAreaRecords = await getRecords(subarea, subarea.bundle, subarea.section, subarea.region, true, false, dateRangeStart, dateRangeEnd);
records = records.concat(subAreaRecords);
Expand Down
3 changes: 2 additions & 1 deletion arSam/handlers/export/invokable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"author": "Team Osprey",
"dependencies": {
"write-excel-file": "^1.3.16"
"write-excel-file": "^1.3.16",
"luxon": "^3.2.1"
}
}
Loading

0 comments on commit eab1ac6

Please sign in to comment.