Files
sumoc-backend/src/main/java/SuMoC/backend/trenddetection/models/WeeklyMobilityStats.java
T
neuhauss 6e458edd5c
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
implement trend detection logic
- for now aimed to detect weekly trends in car distances, easily extendable to all other attributes of the statsm model
- including test
2026-01-07 15:28:35 +01:00

88 lines
1.9 KiB
Java

package SuMoC.backend.trenddetection.models;
import SuMoC.backend.trenddetection.enums.StatAttribute;
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;
public Long getValueFor(StatAttribute attribute) {
return switch (attribute) {
case CAR_DISTANCE -> sumMetersCar;
};
}
}