V 1.6.0 fix: Tagesregen per MAX (kumulierter Tageszähler, Reset um Mitternacht)

Wochenwerte als Summe täglicher Maxima; /weather/stats mit Subquery über tägliche Maxima.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-01 17:31:07 +02:00
parent 4f89db49b6
commit 9c2855fa98
5 changed files with 41 additions and 27 deletions
+2 -2
View File
@@ -26,8 +26,8 @@ function buildUrls(timeRange) {
const days = timeRange.days || 1
const path = days >= 7 ? 'daily-aggregated-range' : 'hourly-aggregated-range'
return {
weatherUrl: `${API_BASE}/weather/${path}?start=${start}&end=${end}`,
rainUrl: null, // TODO: Regen-Aggregation fuer Range implementieren
weatherUrl: `${API_BASE}/weather/${path}?start=${start}&end=${end}`,
rainUrl: days < 7 ? `${API_BASE}/weather/daily-aggregated-range?start=${start}&end=${end}` : null,
needsCurrent: true,
}
}
+7 -5
View File
@@ -171,14 +171,14 @@ const WeatherDashboard = ({ data, currentData = [], rainData = [], timeRange = '
// Spezieller Suffix für Regen
const rainSuffix = useMemo(() => {
if (typeof timeRange === 'object' && timeRange.type === 'custom') {
const days = timeRange.days || 1
return days >= 7 ? ' (pro Tag)' : ''
return ' (pro Tag)'
}
switch (timeRange) {
case '7d':
case '30d':
case '365d':
return ' (pro Tag)'
case '365d':
return ' (pro Woche)'
default:
return ''
}
@@ -639,11 +639,13 @@ const WeatherDashboard = ({ data, currentData = [], rainData = [], timeRange = '
}
}]
} else if (typeof timeRange === 'object' && timeRange.type === 'custom') {
// Custom range: tägliche Summen aus sortedData (total_rain ist im daily-aggregated-range enthalten)
// Custom range: tägliche Summen — bei kurzen Ranges (<7d) aus rainData (extra Fetch),
// bei langen Ranges aus sortedData (daily-aggregated-range enthält total_rain)
yAxisTitle = 'Regen (mm pro Tag)'
const rainSource = rainData.length > 0 ? rainData : sortedData
series = [{
name: 'Regen',
data: sortedData
data: rainSource
.filter(item => item.total_rain != null && item.total_rain > 0)
.map(item => [new Date(item.datetime).getTime(), item.total_rain]),
color: 'rgb(54, 162, 235)',