I have a job running every 5 minutes, checking for a row that hasn't been updated in the last 24 hours
At the top level of the file i.e. NOT in the job function, I define it as such
const oneDayAgo = new Date(Date.now() - 1000 * 60 * 60 * 24);export const jobThatExecutes = () => {// job here that uses it}
const oneDayAgo = new Date(Date.now() - 1000 * 60 * 60 * 24);export const jobThatExecutes = () => {// job here that uses it}
I can see in my logs that it currently evaluates "one day ago" as 16th June, when today is 18th June - and the last updated row is evaluating to 17th June (30 hours ago from now), meaning it should be updated if the one day ago is correct - which it appears not to be.
I am going to try and updated it now to move the 24 hours ago variable into the function itself, but wanted to check what default behaviour was, and have this asked in case people search for the future!