Skip to content

Commit

Permalink
Added scheduler correction with timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
anoopkarnik committed Aug 21, 2024
1 parent 577467d commit 4ac37e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/dashboard-app/routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

export const publicRoutes = [
"/landing","/auth/new-verification",'/api'
"/landing","/auth/new-verification",'/api/hooks/catch'
]

export const authRoutes =[
Expand Down
12 changes: 6 additions & 6 deletions apps/scheduler/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ async function main() {
if (workflow.trigger?.type.name === 'Cron'){
logger.info(`Processing cron workflow ${workflow.id}`);
const metadata:any = workflow.trigger?.metadata;
const startDate = new Date(metadata?.startDate);
const now = new Date();
const timezone = metadata?.timezone;
const startDate = moment(metadata?.startDate).tz(timezone).toDate();
const now = moment().tz(timezone).toDate();
const cronExpression = metadata?.cronExpression;
let lastRun;
if (workflow.lastRun){
lastRun = new Date(workflow.lastRun);
lastRun = moment(workflow.lastRun).tz(timezone).toDate();
}
else{
lastRun = new Date(metadata.startDate);
lastRun = moment(metadata.startDate).tz(timezone).toDate();
}
const interval = cronParser.parseExpression(cronExpression,{currentDate: lastRun, tz: timezone});
let nextRun:Date = interval.next().toDate ();
const local_time = moment(new Date())
let nextRun:Date = interval.next().toDate();
const local_time = moment().tz(timezone);
let eventMetadata = {
trigger: {
result:{
Expand Down

0 comments on commit 4ac37e3

Please sign in to comment.