feat: store full datetime in sleep_segments JSONB
Enhanced sleep_segments data structure:
- start: ISO datetime (2026-03-21T22:30:00) instead of HH:MM
- end: ISO datetime (2026-03-21T23:15:00) - NEW
- phase: sleep phase type
- duration_min: duration in minutes
Benefits:
- Exact timestamp for each segment (no date ambiguity)
- Can reconstruct complete sleep timeline
- Enables precise cycle analysis
- Handles midnight crossings correctly
Example:
[
{"phase": "light", "start": "2026-03-21T22:30:00", "end": "2026-03-21T23:15:00", "duration_min": 45},
{"phase": "deep", "start": "2026-03-21T23:15:00", "end": "2026-03-22T00:30:00", "duration_min": 75}
]
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9a9c597187
commit
da376a8b18
|
|
@ -545,11 +545,12 @@ async def import_apple_health_sleep(
|
|||
night['awake_minutes']
|
||||
)
|
||||
|
||||
# Prepare JSONB segments
|
||||
# Prepare JSONB segments with full datetime
|
||||
sleep_segments = [
|
||||
{
|
||||
'phase': seg['phase'],
|
||||
'start': seg['start'].strftime('%H:%M'),
|
||||
'start': seg['start'].isoformat(), # Full datetime: 2026-03-21T22:30:00
|
||||
'end': seg['end'].isoformat(), # Full datetime: 2026-03-21T23:15:00
|
||||
'duration_min': seg['duration_min']
|
||||
}
|
||||
for seg in night['segments']
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user