diff --git a/src/main/java/org/avniproject/etl/domain/quartz/ScheduledJobRun.java b/src/main/java/org/avniproject/etl/domain/quartz/ScheduledJobRun.java index d3fe24c..7251666 100644 --- a/src/main/java/org/avniproject/etl/domain/quartz/ScheduledJobRun.java +++ b/src/main/java/org/avniproject/etl/domain/quartz/ScheduledJobRun.java @@ -35,11 +35,12 @@ public class ScheduledJobRun { public static ScheduledJobRun create(JobDetail jobDetail, Trigger trigger) { ScheduledJobRun scheduledJobRun = new ScheduledJobRun(); scheduledJobRun.jobName = jobDetail.getKey().getName(); - scheduledJobRun.startedAt = trigger.getStartTime(); + scheduledJobRun.startedAt = trigger.getNextFireTime(); return scheduledJobRun; } - public void ended(JobExecutionException jobException) { + public void ended(JobExecutionException jobException, Trigger trigger) { + this.startedAt = trigger.getPreviousFireTime(); this.endedAt = new Date(); if (jobException != null) errorMessage = ExceptionUtil.getStackTraceAsString(getAppException(jobException)); diff --git a/src/main/java/org/avniproject/etl/scheduler/EtlJobListener.java b/src/main/java/org/avniproject/etl/scheduler/EtlJobListener.java index 0b68494..5772fc5 100644 --- a/src/main/java/org/avniproject/etl/scheduler/EtlJobListener.java +++ b/src/main/java/org/avniproject/etl/scheduler/EtlJobListener.java @@ -49,7 +49,7 @@ public void jobWasExecuted(JobExecutionContext context, JobExecutionException jo log.error("Error in job run", jobException); } ScheduledJobRun scheduledJobRun = scheduledJobRunRepository.getLastRun(context.getJobDetail().getKey().getName()); - scheduledJobRun.ended(jobException); + scheduledJobRun.ended(jobException, context.getTrigger()); scheduledJobRun.setSuccess(jobException == null); scheduledJobRunRepository.save(scheduledJobRun); } catch (Exception exception) {