From 5f7d6908755ca36ce092bd8ef1d3bd2480d6d8ac Mon Sep 17 00:00:00 2001 From: schrom01 Date: Fri, 9 Dec 2022 21:27:13 +0100 Subject: [PATCH] fixed not showing past tasks --- .../ch/zhaw/gartenverwaltung/models/GardenSchedule.java | 7 ++----- src/main/java/ch/zhaw/gartenverwaltung/types/Task.java | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java b/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java index 2e3eb3d..74d67dd 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java @@ -176,13 +176,10 @@ public class GardenSchedule { dayTaskList.add(new ArrayList<>()); final int finalI = i; weekTasks.forEach(task -> { - if (task.getNextExecution() == null) { - task.isDone(); - } else { + if(task.getNextExecution() != null) { LocalDate checkDate = task.getNextExecution(); - do { - if (date.equals(checkDate) && !date.isAfter(task.getEndDate().orElse(LocalDate.MIN))) { + if (date.equals(task.getNextExecution()) || (date.equals(checkDate) && !date.isAfter(task.getEndDate().orElse(LocalDate.MIN)))) { dayTaskList.get(finalI).add(task); } checkDate = checkDate.plusDays(task.getInterval().orElse(0)); diff --git a/src/main/java/ch/zhaw/gartenverwaltung/types/Task.java b/src/main/java/ch/zhaw/gartenverwaltung/types/Task.java index d235918..c6eb57a 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/types/Task.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/types/Task.java @@ -107,7 +107,7 @@ public class Task { * @return Whether the Task is within the given range */ public boolean isInTimePeriod(LocalDate searchStartDate, LocalDate searchEndDate) { - return endDate.isAfter(searchStartDate) && startDate.isBefore(searchEndDate) || (nextExecution != null && nextExecution.isBefore(searchEndDate) && nextExecution.isAfter(searchStartDate)); + return (endDate.isAfter(searchStartDate) && startDate.isBefore(searchEndDate)) || ((nextExecution != null && nextExecution.isBefore(searchEndDate.plusDays(1)) && nextExecution.isAfter(searchStartDate.minusDays(1)))); } /**