Fix segment effort duplicates; auto-scan on segment creation

- detect.py: truncate started_at to seconds so dedup key survives JSON round-trip
- store.py: dedup by (activity_id, iso-started_at) string key, not object equality
- server.py: extract _scan_segment_for_user helper; trigger background scan
  for the creating user's activities when a new segment is saved
This commit is contained in:
Davide Scaini
2026-05-13 15:58:57 +02:00
parent cb3c9b6e41
commit 2395a6e566
3 changed files with 31 additions and 23 deletions
+1 -1
View File
@@ -197,7 +197,7 @@ def _extract_effort(
j: int,
) -> SegmentEffort:
elapsed_s = track.times[j] - track.times[i]
started_at = track.started_at + timedelta(seconds=track.times[i])
started_at = (track.started_at + timedelta(seconds=track.times[i])).replace(microsecond=0)
avg_speed = _avg_nonnull(track.speeds, i, j)
avg_hr_raw = _avg_nonnull(track.hrs, i, j)
avg_hr = int(round(avg_hr_raw)) if avg_hr_raw is not None else None