Skip to content

fix: correct data display bugs (missing days and months)#109

Open
jrozelle wants to merge 2 commits intoMyElectricalData:mainfrom
jrozelle:fix/data-display-bugs
Open

fix: correct data display bugs (missing days and months)#109
jrozelle wants to merge 2 commits intoMyElectricalData:mainfrom
jrozelle:fix/data-display-bugs

Conversation

@jrozelle
Copy link

@jrozelle jrozelle commented Feb 20, 2026

Summary

Bug fixes (commit 1)

Backend - date < end_date → date <= end_date (local_data.py)

  • En mode CLIENT, enedis_client.py ne passe pas par adjust_date_range(), donc le end_date du frontend est utilisé directement
  • date < end_date excluait la dernière journée (hier) des résultats
  • Corrigé en date <= end_date dans _get_energy_data et _find_missing_ranges (3 endroits)

Frontend - endDate = yesterday → today (6 fichiers)

  • useConsumptionFetch.ts, useProductionFetch.ts, useDataFetch.ts, ConsumptionEuro/index.tsx, ConsumptionKwh/index.tsx, Production/index.tsx
  • Le frontend envoyait end=yesterday mais le backend a besoin de end=today avec <= pour inclure hier

Frontend - invalidateQueries key mismatch (3 endroits)

  • invalidateQueries({ queryKey: ['consumption', ...] }) ne matchait pas ['consumptionDaily', ...]
  • Cliquer "Récupérer" ne re-fetchait jamais les données quotidiennes — le cache périmé était réutilisé
  • Même problème avec 'production' vs 'productionDaily'

Frontend - déduplication Tempo écrasait les périodes complètes (useConsumptionCalcs.ts)

  • "2024-2025" apparaissait d'abord comme previousMonths de "2025-2026" (6 mois partiels)
  • Puis comme currentMonths complet (12 mois), mais le dedup le supprimait
  • Corrigé pour garder l'entrée avec le plus de mois

Features (commit 2)

  • Ajout modèle MaxPowerData + migration alembic
  • Endpoint max power local-first dans enedis_client.py
  • Améliorations sync, scheduler, exporters MQTT/HA
  • Support config runtime env (entrypoint.sh)

Test plan

  • Vérifier que la courbe de charge détaillée affiche les données d'hier (J-1)
  • Vérifier que le graphique Tempo 2024-2025 affiche 12 mois
  • Cliquer "Récupérer" et vérifier que les données quotidiennes sont re-fetchées
  • Vérifier l'export MQTT/HA fonctionne correctement

🤖 Generated with Claude Code

jrozelle and others added 2 commits February 20, 2026 16:40
Backend:
- local_data.py: change `date < end_date` to `date <= end_date` in
  _get_energy_data and _find_missing_ranges (3 locations). In client mode,
  enedis_client.py does NOT call adjust_date_range(), so the end_date
  passed directly from the frontend must be treated as inclusive.
  This caused yesterday's data to be excluded from query results.

Frontend - endDate off-by-one:
- useConsumptionFetch.ts, useProductionFetch.ts, useDataFetch.ts,
  ConsumptionEuro/index.tsx, ConsumptionKwh/index.tsx, Production/index.tsx:
  change endDate from `yesterday` to `today` so that with the inclusive
  backend query (date <= end_date), yesterday's data is included.

Frontend - invalidateQueries key mismatch:
- useConsumptionFetch.ts: `['consumption', ...]` → `['consumptionDaily', ...]`
- useConsumptionFetch.ts: `['production', ...]` → `['productionDaily', ...]`
- useProductionFetch.ts: `['production', ...]` → `['productionDaily', ...]`
  The query keys did not match, so clicking "Fetch" never invalidated the
  daily data cache. Stale/incomplete data was reused instead of refetching.

Frontend - Tempo chart deduplication bug:
- useConsumptionCalcs.ts: the yearsByPreset dedup kept the first occurrence
  of each label. "2024-2025" appeared first as previousMonths of "2025-2026"
  (6 months only), then as currentMonths (12 months complete). The old dedup
  discarded the complete version. Fixed to keep the entry with the most months.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Backend:
- Add MaxPowerData model and alembic migration
- Add max power local-first endpoint in enedis_client.py
- Enhance sync service with better error handling and retry logic
- Improve Home Assistant exporter with detailed consumption/production data
- Improve MQTT exporter configuration
- Add scheduler improvements for data fetching timing
- Fix ecowatt router minor issues

Frontend:
- Add runtime env config support (entrypoint.sh, vite-env.d.ts)
- Improve PDLDetails display
- Refactor HomeAssistant and MQTT configuration pages
- Fix VictoriaMetrics page minor issues

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant