add weekly schedulded task that calculates weekly mobility statistics for each user that made a trip in that week -> basis for deteting trend changes in mobility behaviour
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good

This commit is contained in:
2026-01-06 17:55:04 +01:00
parent 17636f0b65
commit c010f34479
14 changed files with 374 additions and 7 deletions
@@ -0,0 +1,33 @@
package SuMoC.backend.dev;
import SuMoC.backend.scheduling.ScheduledTasks;
import SuMoC.backend.trenddetection.services.UpdateStatsTablesService;
import lombok.RequiredArgsConstructor;
import org.springframework.cglib.core.Local;
import org.springframework.context.annotation.Profile;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate;
@RestController
@RequestMapping("/dev")
@Profile("dev")
@RequiredArgsConstructor
public class DevController {
private final ScheduledTasks scheduledTasks;
private final UpdateStatsTablesService updateStatsTablesService;
@PostMapping("/trigger-trend-calculation")
public void triggerTrendCalculation() {
LocalDate dayOfLastWeek = LocalDate.now().minusDays(7);
LocalDate day2WeeksAgo = LocalDate.now().minusDays(14);
LocalDate day3WeeksAgo = LocalDate.now().minusDays(21);
updateStatsTablesService.updateWeeklyMobilityStatsForAllUsers(dayOfLastWeek);
updateStatsTablesService.updateWeeklyMobilityStatsForAllUsers(day2WeeksAgo);
updateStatsTablesService.updateWeeklyMobilityStatsForAllUsers(day3WeeksAgo);
}
}