feat: Refactor activity import logic and enhance CSV handling
Deploy Development / deploy (push) Successful in 56s
Build Test / pytest-backend (push) Successful in 4s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 16s

- Replaced the deprecated `resolve_activity_log_column_patch_from_csv` function with `activity_csv_registry_updates_from_mapped` to streamline updates from CSV mappings.
- Updated the `_import_activity` function to utilize the new registry updates, improving data integrity during activity imports.
- Enhanced the activity module registry by adding German labels for various fields, improving localization support.
- Refactored the session metrics handling to ensure only relevant fields are processed, enhancing the overall robustness of CSV imports.
This commit is contained in:
Lars committed 2026-04-15 10:35:48 +02:00
1 parent 9d47c4ef84
commit 08eae86ddc
6 files changed
+181 -93

No files matched your search

@@ -297,10 +297,19 @@ export default function AdminCsvTemplateEditorPage() {
const aggregateSleepImport = modMeta?.import_mode === 'apple_sleep_aggregate'
const targetOptions = useMemo(() => {
if (!modMeta?.fields || aggregateSleepImport) return []
return Object.entries(modMeta.fields).map(([key, meta]) => ({
value: key,
label: `${key}${meta.required ? ' *' : ''}`,
}))
const entries = Object.entries(modMeta.fields).map(([key, meta]) => {
const title = meta.label_de || meta.name_de || key
return {
value: key,
label: `${title}${meta.required ? ' *' : ''}`,
group: meta.from_training_parameter ? 'eav' : 'log',
}
})
entries.sort((a, b) => {
if (a.group !== b.group) return a.group === 'log' ? -1 : 1
return a.label.localeCompare(b.label, 'de')
})
return entries
}, [modMeta, aggregateSleepImport])
const requiredTargets = useMemo(() => {
@@ -1025,11 +1034,23 @@ export default function AdminCsvTemplateEditorPage() {
}}
>
<option value="-">— ignorieren</option>
{targetOptions.map((o) => (
<option key={o.value} value={o.value}>
{o.label}
</option>
))}
{['log', 'eav'].map((g) => {
const opts = targetOptions.filter((o) => o.group === g)
if (!opts.length) return null
const ogLabel =
g === 'log'
? 'Activity — Kernfelder (activity_log)'
: 'Trainingsparameter (EAV)'
return (
<optgroup key={g} label={ogLabel}>
{opts.map((o) => (
<option key={o.value} value={o.value}>
{o.label}
</option>
))}
</optgroup>
)
})}
</select>
</div>
))}