From 2dc0b4e27c8476f0d8ddbf5af92c55732273ecf8 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Mon, 19 Nov 2018 07:46:02 +0400 Subject: [PATCH] fix event create conditions --- src/main/java/ru/ulstu/timeline/service/EventScheduler.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/ru/ulstu/timeline/service/EventScheduler.java b/src/main/java/ru/ulstu/timeline/service/EventScheduler.java index 7a0bc66..6df7fcb 100644 --- a/src/main/java/ru/ulstu/timeline/service/EventScheduler.java +++ b/src/main/java/ru/ulstu/timeline/service/EventScheduler.java @@ -40,7 +40,8 @@ public class EventScheduler { @Scheduled(cron = "0 0 * * * ?") public void checkPeriodEvents() { log.debug("EventScheduler.checkPeriodEvents started"); - for (Event event : eventService.findAllFuture()) { + //TODO: filter + for (Event event : eventService.findAll()) { if (halfOfThePeriodHasPassed(event)) { eventService.createBasedOn(event, DateUtils.addDays(event.getExecuteDate(), getShiftInDays(event.getPeriod()))); } @@ -67,6 +68,6 @@ public class EventScheduler { private boolean halfOfThePeriodHasPassed(Event event) { return event.getPeriod() != null && event.getChild() == null && new Date().after( - DateUtils.addDays(event.getExecuteDate(), (int) -Math.round((double) getShiftInDays(event.getPeriod()) / 2))); + DateUtils.addDays(event.getExecuteDate(), (int) Math.round((double) getShiftInDays(event.getPeriod()) / 2))); } }