implement full service chain where scheduled task detects regular trips every day and schedules notifications with better alternatives if available
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package SuMoC.backend.scheduling;
|
||||
|
||||
import SuMoC.backend.notification.services.NotificationWorker;
|
||||
import SuMoC.backend.suggestion.services.RegularTripSuggestionService;
|
||||
import SuMoC.backend.trend.services.StatTableUpdateService;
|
||||
import SuMoC.backend.trend.services.TrendNotificationService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -23,6 +24,8 @@ public class ScheduledTasks {
|
||||
|
||||
private final TrendNotificationService trendNotificationService;
|
||||
|
||||
private final RegularTripSuggestionService regularTripSuggestionService;
|
||||
|
||||
private final NotificationWorker notificationWorker;
|
||||
|
||||
/**
|
||||
@@ -65,4 +68,17 @@ public class ScheduledTasks {
|
||||
logger.error("Error cleaning up old notifications.", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect regular routes for all users and plan notifications for better alternatives.
|
||||
*/
|
||||
@Scheduled(cron = "#{@schedulingProperties.notifyRegularRouteAlternatives}")
|
||||
public void scheduleNotifyRegularRouteAlternatives() {
|
||||
logger.info("Scheduled task triggered: notifyRegularRouteAlternatives");
|
||||
try {
|
||||
regularTripSuggestionService.detectAndNotifyRegularTripsForTodaysDayOfWeek();
|
||||
} catch (Exception e) {
|
||||
logger.error("Error notifying regular route alternatives.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user