Skip to content

Commit

Permalink
#48 | Set the ETL ScheduledJobRun startTime based on trigger fireTime.
Browse files Browse the repository at this point in the history
  • Loading branch information
himeshr committed Aug 21, 2023
1 parent d471b4f commit 19591ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 19591ac

Please sign in to comment.