Skip to content

Instantly share code, notes, and snippets.

@gagregrog
Last active October 27, 2020 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gagregrog/17a5678ca1212723e7193c9940c3a9a9 to your computer and use it in GitHub Desktop.
Save gagregrog/17a5678ca1212723e7193c9940c3a9a9 to your computer and use it in GitHub Desktop.
Process Covid Results
require('dotenv').config();
const processOne = require('./lib/process');
const DEFAULT_DELAY = 1;
const ENV_HRS = Number(process.env.DELAY_HRS);
const DELAY_HOURS = ENV_HRS > 0 ? ENV_HRS : DEFAULT_DELAY;
const DELAY_MS = DELAY_HOURS * 1000 * 60 * 60; // X hrs * 1000 ms/sec * 60 sec/min * 60 min/hr
const loop = async () => {
try {
await processOne({ dob: process.env.DOB, barcode: process.env.CODE });
} catch (error) {
console.log(error);
}
setTimeout(loop, DELAY_MS);
}
const main = async () => {
console.log(`Checking for results every ${DELAY_HOURS} hour${DELAY_HOURS === 1 ? '' : 's'}\n`);
loop();
}
if (require.main === module) {
main();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment