mitai-jinkendo/backend/migrations/045_sleep_template_schlafanalyse_cols.sql
Lars 41cc0ed2a8
Some checks failed
Deploy Development / deploy (push) Successful in 54s
Build Test / pytest-backend-csv (push) Failing after 4s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 16s
feat(csv-import): Enhance Apple sleep CSV import functionality
- Integrated date parsing improvements using dateutil for better handling of various date formats in sleep data.
- Added total sleep hours to the nights dictionary for comprehensive sleep analysis.
- Updated the import logic to handle cases where sleep duration is zero, providing appropriate warnings.
- Enhanced the CSV import interface to detect Apple sleep CSV format and provide user feedback on template selection.
- Improved the admin CSV template editor to accommodate new sleep import requirements and clarify usage instructions.
2026-04-10 07:52:04 +02:00

28 lines
893 B
SQL

-- Migration 045: Schlaf-Systemvorlage — Signatur wie „Schlafanalyse“-Export (Date/Time, Sources, …)
-- Ergänzt die Vorlage aus 044 für besseres Matching; Import-Logik unverändert (Apple-Aggregat-Parser).
UPDATE csv_field_mappings
SET
column_signature = ARRAY[
'Date/Time',
'Start',
'End',
'Total Sleep (hr)',
'Asleep (Unspecified) (hr)',
'In Bed (hr)',
'Core (hr)',
'Deep (hr)',
'REM (hr)',
'Awake (hr)',
'Sources'
]::TEXT[],
description = COALESCE(
description,
'Apple-Health-Schlafanalyse (Nacht-Zusammenfassung): Spalten wie Date/Time, Start/End mit Zeitzone, Kern/Tief/REM etc.'
),
updated_at = CURRENT_TIMESTAMP
WHERE is_system = true
AND profile_id IS NULL
AND module = 'sleep'
AND mapping_name = 'Apple Health Schlaf (Schlafanalyse / Nacht)';