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

This commit is contained in:
2026-01-16 13:19:19 +01:00
parent b08d9dd22d
commit d099909aab
13 changed files with 299 additions and 24 deletions
@@ -142,6 +142,38 @@ public class RoutingService {
return routes;
}
public RouteDTO determineBestAlternativeRouteForRegularTrip(RoutingAlternativeRequestDTO requestDTO) {
assert requestDTO.getRoutingPreferencesDTO() != null;
// TODO for now we use adHocRoutingProperties here, in the future we might want to have separate properties for regular trip alternatives
List<RouteDTO> routes = getPossibleAlternativeRoutes(requestDTO);
routes = alternativeFilterService.filterForAdditionalTravelTime(requestDTO, routes, adHocRoutingProperties);
if (requestDTO.getRoutingPreferencesDTO().isConsiderWeatherConditions()) {
routes = alternativeFilterService.filterForBadWeather(requestDTO, routes, adHocRoutingProperties);
}
RouteDTO bestRoute = null;
// if users wants physical activity, we pick the fastest physical activity route, if any
if (requestDTO.getRoutingPreferencesDTO().isPreferPhysicalActivity()) {
bestRoute = routes.stream()
.filter(RouteDTO::isPhysicalActivity)
.min((r1, r2) -> Long.compare(
r1.getDurationSeconds(),
r2.getDurationSeconds()
)).orElse(null);
if (bestRoute != null) {
return bestRoute;
}
}
// else we pick the fastest route overall
bestRoute = routes.stream()
.min((r1, r2) -> Long.compare(
r1.getDurationSeconds(),
r2.getDurationSeconds()
)).orElse(null);
return bestRoute;
}
/**
* Returns possible alternative routes for the request - no sanity filtering regarding travel times etc. is applied.
*/