feat: Refactor activity import logic and enhance CSV handling
- 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:
1 parent
9d47c4ef84
commit
08eae86ddc
6 files changed
+181
-93
No files matched your search
@@ -98,20 +98,21 @@ function buildMetricsPayload(schema, draft) {
|
||||
out.push({ parameter_key: s.key, value: !!raw })
|
||||
continue
|
||||
}
|
||||
if (raw === '' || raw === null || raw === undefined) {
|
||||
const rawStr = raw === null || raw === undefined ? '' : String(raw).trim()
|
||||
if (rawStr === '') {
|
||||
if (s.required) throw new Error(`Pflichtfeld: ${s.name_de}`)
|
||||
out.push({ parameter_key: s.key, value: null })
|
||||
continue
|
||||
}
|
||||
let v = raw
|
||||
let v
|
||||
if (s.data_type === 'integer') {
|
||||
v = parseInt(String(raw), 10)
|
||||
v = parseInt(rawStr, 10)
|
||||
if (Number.isNaN(v)) throw new Error(`Ungültige Zahl: ${s.name_de}`)
|
||||
} else if (s.data_type === 'float') {
|
||||
v = parseFloat(String(raw))
|
||||
v = parseFloat(rawStr)
|
||||
if (Number.isNaN(v)) throw new Error(`Ungültige Zahl: ${s.name_de}`)
|
||||
} else {
|
||||
v = String(raw)
|
||||
v = rawStr
|
||||
}
|
||||
out.push({ parameter_key: s.key, value: v })
|
||||
}
|
||||
@@ -532,21 +533,22 @@ export default function ActivityPage() {
|
||||
if (!col || !ACTIVITY_LOG_PAYLOAD_KEYS.has(col)) continue
|
||||
if (!(s.key in metricDraft)) continue
|
||||
const raw = metricDraft[s.key]
|
||||
if (raw === '' || raw === null || raw === undefined) {
|
||||
const rawStr = raw === null || raw === undefined ? '' : String(raw).trim()
|
||||
if (rawStr === '') {
|
||||
payload[col] = null
|
||||
continue
|
||||
}
|
||||
let v = raw
|
||||
let v = rawStr
|
||||
if (s.data_type === 'integer') {
|
||||
v = parseInt(String(raw), 10)
|
||||
if (Number.isNaN(v)) continue
|
||||
v = parseInt(rawStr, 10)
|
||||
if (Number.isNaN(v)) throw new Error(`Ungültige Zahl: ${s.name_de}`)
|
||||
} else if (s.data_type === 'float') {
|
||||
v = parseFloat(String(raw))
|
||||
if (Number.isNaN(v)) continue
|
||||
v = parseFloat(rawStr)
|
||||
if (Number.isNaN(v)) throw new Error(`Ungültige Zahl: ${s.name_de}`)
|
||||
} else if (s.data_type === 'boolean') {
|
||||
v = !!raw
|
||||
} else {
|
||||
v = String(raw)
|
||||
v = rawStr
|
||||
}
|
||||
payload[col] = v
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user