Small visual fixes
This commit is contained in:
parent
7c957e5135
commit
566fc90249
4 changed files with 59 additions and 10 deletions
|
|
@ -158,11 +158,60 @@ public class TrainingLoadService {
|
|||
|
||||
/**
|
||||
* Get recent training load (last 30 days).
|
||||
* Fills in missing days (rest days) with zero TSS but calculated ATL/CTL/TSB.
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public List<TrainingLoad> getRecentTrainingLoad(UUID userId, int days) {
|
||||
LocalDate startDate = LocalDate.now().minusDays(days - 1);
|
||||
return trainingLoadRepository.findByUserIdSinceDate(userId, startDate);
|
||||
LocalDate endDate = LocalDate.now();
|
||||
|
||||
// Get existing training load data
|
||||
List<TrainingLoad> existingData = trainingLoadRepository.findByUserIdSinceDate(userId, startDate);
|
||||
|
||||
// Create a map of date -> TrainingLoad for quick lookup
|
||||
java.util.Map<LocalDate, TrainingLoad> dataMap = new java.util.HashMap<>();
|
||||
for (TrainingLoad tl : existingData) {
|
||||
dataMap.put(tl.getDate(), tl);
|
||||
}
|
||||
|
||||
// Fill in missing days
|
||||
List<TrainingLoad> result = new java.util.ArrayList<>();
|
||||
LocalDate currentDate = startDate;
|
||||
|
||||
while (!currentDate.isAfter(endDate)) {
|
||||
if (dataMap.containsKey(currentDate)) {
|
||||
// Day with activity - use existing data
|
||||
result.add(dataMap.get(currentDate));
|
||||
} else {
|
||||
// Rest day - create entry with zero TSS but calculate rolling averages
|
||||
TrainingLoad restDay = createRestDayEntry(userId, currentDate);
|
||||
result.add(restDay);
|
||||
}
|
||||
currentDate = currentDate.plusDays(1);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a TrainingLoad entry for a rest day (no activities).
|
||||
* Calculates ATL, CTL, TSB based on previous days.
|
||||
*/
|
||||
private TrainingLoad createRestDayEntry(UUID userId, LocalDate date) {
|
||||
TrainingLoad restDay = TrainingLoad.builder()
|
||||
.userId(userId)
|
||||
.date(date)
|
||||
.activityCount(0)
|
||||
.totalDurationSeconds(0L)
|
||||
.totalDistanceMeters(BigDecimal.ZERO)
|
||||
.totalElevationGainMeters(BigDecimal.ZERO)
|
||||
.trainingStressScore(BigDecimal.ZERO)
|
||||
.build();
|
||||
|
||||
// Calculate rolling averages using existing data
|
||||
calculateRollingAverages(restDay, userId, date);
|
||||
|
||||
return restDay;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@
|
|||
<div layout:fragment="content">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2>
|
||||
<div class="mb-4">
|
||||
<h2 class="mb-3">
|
||||
<i class="bi bi-people text-primary"></i>
|
||||
Following Timeline
|
||||
</h2>
|
||||
<div class="btn-group" role="group" aria-label="Timeline views">
|
||||
<div class="btn-group w-100 w-md-auto" role="group" aria-label="Timeline views">
|
||||
<a th:href="@{/timeline}" class="btn btn-outline-primary">
|
||||
<i class="bi bi-globe"></i> Public
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@
|
|||
<div layout:fragment="content">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2>
|
||||
<div class="mb-4">
|
||||
<h2 class="mb-3">
|
||||
<i class="bi bi-globe text-primary"></i>
|
||||
Public Timeline
|
||||
</h2>
|
||||
<div class="btn-group" role="group" aria-label="Timeline views">
|
||||
<div class="btn-group w-100 w-md-auto" role="group" aria-label="Timeline views">
|
||||
<a th:href="@{/timeline}" class="btn btn-primary active">
|
||||
<i class="bi bi-globe"></i> Public
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@
|
|||
<div layout:fragment="content">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2>
|
||||
<div class="mb-4">
|
||||
<h2 class="mb-3">
|
||||
<i class="bi bi-person text-primary"></i>
|
||||
My Timeline
|
||||
</h2>
|
||||
<div class="btn-group" role="group" aria-label="Timeline views">
|
||||
<div class="btn-group w-100 w-md-auto" role="group" aria-label="Timeline views">
|
||||
<a th:href="@{/timeline}" class="btn btn-outline-primary">
|
||||
<i class="bi bi-globe"></i> Public
|
||||
</a>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue