So in my application I am cron parsing multiple database data and I have it right now to where I create a const run for each data to find the dag_id and test the determineCron one at a time manually. How would I make an array so that the "determineCron()" at the bottom will test every run instead of me just manually coding determineCron(run), determineCron(run2), determineCron(run3), determineCron(run4) etc.
const run = {
start_date: '2022-07-01T13:45:01.221636+00:00',
end_date: '2022-07-01T14:11:01.864293+00:00',
state: 'success',
dag_run_id: 'scheduled__2022-06-30T13:45:00+00:00',
dag_id: 'IPP_CYCLE_PARMS',
}
const run2 = {
start_date: '2022-06-26T23:00:00.742495+00:00',
end_date: '2022-06-27T14:10:23.108401+00:00',
state: 'failed',
dag_run_id: 'scheduled__2022-06-25T23:00:00+00:00',
dag_id: 'EFS-Winning-Route-daily-batch'
}
async function determineCron(result){
/*dagID = result?.[0]?.dag_id || 0*/
dagID = result ? result.dag_id : 0
console.log(dagID)
job = await bqConnection().query(`SELECT * FROM \`np-inventory-planning-thd.IPP_SLA.expected_sla\` where dag_id = "${dagID}"`)
console.log(job[0][0]);
cronTime = job[0][0].cron_time
var interval = parser.parseExpression(cronTime);
console.log('Date: ', interval.next().toString());
}
determineCron(run)
determineCron(run2)