Skip to content

Commit

Permalink
Refactor dts-process.js and imtd-process.js to use rloiids instead of…
Browse files Browse the repository at this point in the history
… stations
  • Loading branch information
nikiwycherley committed May 10, 2024
1 parent 73fdb67 commit e00d040
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions lib/functions/dts-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ async function handler ({ offset = 0 } = {}) {
const BATCH_SIZE = parseInt(process.env.IMTD_BATCH_SIZE || '500')

logger.info(`Retrieving up to ${BATCH_SIZE} rloi_ids with an offset of ${offset}`)
const stations = await getRloiIds({
const rloiids = await getRloiIds({
offset,
limit: BATCH_SIZE
})
logger.info(`Retrieved ${stations.length} rloi_ids`)
logger.info(`Retrieved ${rloiids.length} rloi_ids`)

for (const station of stations) {
await getData(station.rloi_id)
for (const rloiid of rloiids) {
await getData(rloiid.rloi_id)
}

if (stations.length >= BATCH_SIZE) {
if (rloiids.length >= BATCH_SIZE) {
const functionName = process.env.AWS_LAMBDA_FUNCTION_NAME
const newOffset = offset + BATCH_SIZE
logger.info(`Invoking ${functionName} with an offset of ${newOffset}`)
Expand Down
10 changes: 5 additions & 5 deletions lib/functions/imtd-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ async function handler ({ offset = 0 } = {}) {
const BATCH_SIZE = parseInt(process.env.IMTD_BATCH_SIZE || '500')

logger.info(`Retrieving up to ${BATCH_SIZE} rloi_ids with an offset of ${offset}`)
const rloiids = await getRloiIds({
const stations = await getRloiIds({
offset,
limit: BATCH_SIZE
})
logger.info(`Retrieved ${rloiids.length} rloi_ids`)
logger.info(`Retrieved ${stations.length} rloi_ids`)

for (const rloiid of rloiids) {
await getData(rloiid.rloi_id)
for (const station of stations) {
await getData(station.rloi_id)
}

if (rloiids.length >= BATCH_SIZE) {
if (stations.length >= BATCH_SIZE) {
const functionName = process.env.AWS_LAMBDA_FUNCTION_NAME
const newOffset = offset + BATCH_SIZE
logger.info(`Invoking ${functionName} with an offset of ${newOffset}`)
Expand Down

0 comments on commit e00d040

Please sign in to comment.