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,80 @@
package SuMoC.backend.trenddetection.models;
import SuMoC.backend.user.models.User;
import jakarta.persistence.*;
import lombok.*;
@Entity
@Table(name = "weekly_mobility_stats")
@IdClass(WeeklyMobilityStatsId.class)
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WeeklyMobilityStats {
@Id
@ManyToOne
@JoinColumn(name = "user_id", nullable = false)
private User user;
@Id
@Column(nullable = false)
private Integer year;
@Id
@Column(nullable = false)
private Integer weekNumber;
@Column(nullable = false)
private Double totalDistance;
@Column(nullable = false)
private Integer tripCount;
@Column(nullable = false)
private Double sumMobilityScore;
/**
* The average mobility score for the week. sumMobilityScore / tripCount
*/
@Column(nullable = false)
private Double averageMobilityScore;
@Column(nullable = false)
private Long sumMetersTraveled = 0L;
@Column(nullable = false)
private Long sumMetersWalkingAndCycling = 0L;
@Column(nullable = false)
private Long sumMetersPublicTransport = 0L;
@Column(nullable = false)
private Long sumMetersWalking = 0L;
@Column(nullable = false)
private Long sumMetersBicycle = 0L;
@Column(nullable = false)
private Long sumMetersEscooter = 0L;
@Column(nullable = false)
private Long sumMetersBus = 0L;
@Column(nullable = false)
private Long sumMetersTram = 0L;
@Column(nullable = false)
private Long sumMetersTrain = 0L;
@Column(nullable = false)
private Long sumMetersCar = 0L;
@Column(nullable = false)
private Long sumMetersMotorcycle = 0L;
@Column(nullable = false)
private Long sumMetersTaxi = 0L;
}