feat: update history_overview_viz configuration and validation
Deploy Development / deploy (push) Successful in 55s
Build Test / pytest-backend (push) Successful in 4s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 17s

- Replaced the `show_area_summaries` option with individual section visibility settings (`show_section_body`, `show_section_nutrition`, `show_section_fitness`, `show_section_recovery`) in the `history_overview_viz` widget configuration.
- Implemented migration logic to handle legacy `show_area_summaries` settings, ensuring backward compatibility.
- Updated validation logic to enforce visibility requirements for the new section keys.
- Enhanced tests to cover new configuration scenarios and validate the migration logic.
- Bumped application version to reflect these changes.
This commit is contained in:
Lars committed 2026-04-22 12:04:37 +02:00
1 parent 97dbb0f80b
commit 725e7ffe4b
7 files changed
+121 -25

No files matched your search

@@ -3,10 +3,16 @@ import {
normalizeHistoryOverviewVizConfig,
} from './historyOverviewVizConfig'
const TOGGLES = [
const SECTION_TOGGLES = [
{ key: 'show_section_body', label: 'Körper' },
{ key: 'show_section_nutrition', label: 'Ernährung' },
{ key: 'show_section_fitness', label: 'Fitness' },
{ key: 'show_section_recovery', label: 'Erholung' },
]
const OTHER_TOGGLES = [
{ key: 'show_confidence_banner', label: 'Banner «Datenlage»' },
{ key: 'show_intro_blurb', label: 'Hinweistext (Ernährung / API)' },
{ key: 'show_area_summaries', label: 'Kacheln Körper · Ernährung · Fitness · Erholung' },
{ key: 'show_correlation_c1_c3', label: 'Lag-Korrelationen C1–C3 (Charts)' },
{ key: 'show_drivers_c4', label: 'Einflussfaktoren C4' },
]
@@ -34,11 +40,20 @@ export default function HistoryOverviewVizConfigEditor({ config, onChange }) {
return (
<div style={{ marginTop: 10, marginLeft: 28 }}>
<div style={{ fontSize: 12, color: 'var(--text2)', marginBottom: 8, lineHeight: 1.5 }}>
<strong>Gesamtübersicht (Verlauf-Bundle):</strong> konsolidierte Kurzinfos und Korrelations-Kacheln — wie im Verlauf-Reiter «Gesamt».
<strong>Gesamtübersicht (Verlauf-Bundle):</strong> welche Bereichs-Kacheln und weitere Blöcke erscheinen.
</div>
<div style={{ fontSize: 12, color: 'var(--text2)', marginBottom: 6 }}>Bereiche</div>
<div style={{ fontSize: 12, color: 'var(--text2)', marginBottom: 6 }}>Bereichs-Kacheln</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 6, marginBottom: 12 }}>
{SECTION_TOGGLES.map(({ key, label }) => (
<label key={key} style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 13, cursor: 'pointer' }}>
<input type="checkbox" checked={merged[key]} onChange={(e) => setBool(key, e.target.checked)} />
<span>{label}</span>
</label>
))}
</div>
<div style={{ fontSize: 12, color: 'var(--text2)', marginBottom: 6 }}>Weitere Bereiche</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
{TOGGLES.map(({ key, label }) => (
{OTHER_TOGGLES.map(({ key, label }) => (
<label key={key} style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 13, cursor: 'pointer' }}>
<input type="checkbox" checked={merged[key]} onChange={(e) => setBool(key, e.target.checked)} />
<span>{label}</span>
@@ -3,11 +3,21 @@
* `visibility === undefined` → Verlauf-Tab: volle Gesamtübersicht (wie bisher).
*/
export const HISTORY_OVERVIEW_VIZ_SECTION_KEYS = [
'show_section_body',
'show_section_nutrition',
'show_section_fitness',
'show_section_recovery',
]
export const HISTORY_OVERVIEW_VIZ_PAGE_FULL = {
chart_days: 30,
show_confidence_banner: true,
show_intro_blurb: true,
show_area_summaries: true,
show_section_body: true,
show_section_nutrition: true,
show_section_fitness: true,
show_section_recovery: true,
show_correlation_c1_c3: true,
show_drivers_c4: true,
}
@@ -16,7 +26,10 @@ export const HISTORY_OVERVIEW_VIZ_WIDGET_DEFAULTS = {
chart_days: 30,
show_confidence_banner: true,
show_intro_blurb: true,
show_area_summaries: true,
show_section_body: true,
show_section_nutrition: true,
show_section_fitness: true,
show_section_recovery: true,
show_correlation_c1_c3: true,
show_drivers_c4: true,
}
@@ -24,17 +37,29 @@ export const HISTORY_OVERVIEW_VIZ_WIDGET_DEFAULTS = {
const BOOL_KEYS = [
'show_confidence_banner',
'show_intro_blurb',
'show_area_summaries',
...HISTORY_OVERVIEW_VIZ_SECTION_KEYS,
'show_correlation_c1_c3',
'show_drivers_c4',
]
function hasExplicitSectionKeys(raw) {
return HISTORY_OVERVIEW_VIZ_SECTION_KEYS.some((k) => Object.prototype.hasOwnProperty.call(raw, k))
}
/**
* @param {Record<string, unknown>|null|undefined} raw
*/
export function normalizeHistoryOverviewVizConfig(raw) {
const base = { ...HISTORY_OVERVIEW_VIZ_WIDGET_DEFAULTS }
if (!raw || typeof raw !== 'object') return base
if (Object.prototype.hasOwnProperty.call(raw, 'show_area_summaries') && !hasExplicitSectionKeys(raw)) {
const v = raw.show_area_summaries === true
for (const k of HISTORY_OVERVIEW_VIZ_SECTION_KEYS) {
base[k] = v
}
}
for (const k of BOOL_KEYS) {
if (Object.prototype.hasOwnProperty.call(raw, k)) {
base[k] = raw[k] === true