aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/schedule
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-04-20 09:36:05 -0700
committerAnton Tananaev <anton@traccar.org>2024-04-20 09:36:05 -0700
commit8e4e92f84f149ec9f9da6dd601fab06ed55c544c (patch)
tree557ecc159ff7261f24cf50d030ce7cbc1f9701ac /src/main/java/org/traccar/schedule
parent7b3fda2da562ce7b259a232bf9fc5f519c138283 (diff)
downloadtrackermap-server-8e4e92f84f149ec9f9da6dd601fab06ed55c544c.tar.gz
trackermap-server-8e4e92f84f149ec9f9da6dd601fab06ed55c544c.tar.bz2
trackermap-server-8e4e92f84f149ec9f9da6dd601fab06ed55c544c.zip
Improve report schedules logic
Diffstat (limited to 'src/main/java/org/traccar/schedule')
-rw-r--r--src/main/java/org/traccar/schedule/TaskReports.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/schedule/TaskReports.java b/src/main/java/org/traccar/schedule/TaskReports.java
index 3989cd6a0..1d074214c 100644
--- a/src/main/java/org/traccar/schedule/TaskReports.java
+++ b/src/main/java/org/traccar/schedule/TaskReports.java
@@ -43,7 +43,9 @@ import org.traccar.storage.query.Request;
import jakarta.inject.Inject;
import java.util.Collections;
import java.util.Date;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -81,8 +83,9 @@ public class TaskReports implements ScheduleTask {
var lastEvents = calendar.findPeriods(lastCheck);
var currentEvents = calendar.findPeriods(currentCheck);
- if (!lastEvents.isEmpty() && !currentEvents.equals(lastEvents)) {
- Period period = lastEvents.iterator().next();
+ Set<Period> finishedEvents = new HashSet<>(lastEvents);
+ finishedEvents.removeAll(currentEvents);
+ for (Period period : finishedEvents) {
RequestScoper scope = ServletScopes.scopeRequest(Collections.emptyMap());
try (RequestScoper.CloseableScope ignored = scope.open()) {
executeReport(report, period.getStart(), period.getEnd());