V 1.5.8 fix: Tagesregen wieder per SUM (Daten sind inkrementell, nicht kumuliert)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+15
-24
@@ -270,16 +270,11 @@ async def get_weather_statistics(
|
||||
AVG(pressure) as avg_pressure,
|
||||
AVG(wind_speed * 1.60934) as avg_wind_speed,
|
||||
MAX(wind_gust * 1.60934) as max_wind_gust,
|
||||
(SELECT COALESCE(SUM(daily_max), 0) FROM (
|
||||
SELECT MAX(rain) as daily_max
|
||||
FROM weather_data
|
||||
WHERE datetime >= NOW() - make_interval(hours => %s)
|
||||
GROUP BY DATE(datetime)
|
||||
) sub) as total_rain,
|
||||
SUM(rain) as total_rain,
|
||||
COUNT(*) as data_points
|
||||
FROM weather_data
|
||||
WHERE datetime >= NOW() - make_interval(hours => %s)
|
||||
""", (hours, hours))
|
||||
""", (hours,))
|
||||
result = cursor.fetchone()
|
||||
|
||||
if not result or result['data_points'] == 0:
|
||||
@@ -305,7 +300,7 @@ async def get_daily_statistics(
|
||||
AVG(pressure) as avg_pressure,
|
||||
AVG(wind_speed * 1.60934) as avg_wind_speed,
|
||||
MAX(wind_gust * 1.60934) as max_wind_gust,
|
||||
MAX(rain) as total_rain,
|
||||
SUM(rain) as total_rain,
|
||||
COUNT(*) as data_points
|
||||
FROM weather_data
|
||||
WHERE datetime >= NOW() - make_interval(days => %s)
|
||||
@@ -434,7 +429,7 @@ async def get_daily_aggregated_data(
|
||||
MAX(wind_gust * 1.60934)::float as wind_gust,
|
||||
(array_agg(datetime ORDER BY wind_gust DESC NULLS LAST))[1] as max_wind_gust_time,
|
||||
AVG(wind_dir)::float as wind_dir,
|
||||
MAX(rain)::float as total_rain
|
||||
SUM(rain)::float as total_rain
|
||||
FROM weather_data
|
||||
WHERE datetime >= NOW() - make_interval(days => %s)
|
||||
GROUP BY date_trunc('day', datetime)
|
||||
@@ -474,7 +469,7 @@ async def get_daily_with_minmax_data(
|
||||
MAX(wind_gust * 1.60934)::float as wind_gust,
|
||||
(array_agg(datetime ORDER BY wind_gust DESC NULLS LAST))[1] as max_wind_gust_time,
|
||||
AVG(wind_dir)::float as wind_dir,
|
||||
MAX(rain)::float as total_rain
|
||||
SUM(rain)::float as total_rain
|
||||
FROM weather_data
|
||||
WHERE datetime >= NOW() - make_interval(days => %s)
|
||||
GROUP BY date_trunc('day', datetime)
|
||||
@@ -495,7 +490,7 @@ async def get_daily_rain_data(
|
||||
cursor.execute("""
|
||||
SELECT
|
||||
date_trunc('day', datetime) as date,
|
||||
MAX(rain) as total_rain
|
||||
SUM(rain) as total_rain
|
||||
FROM weather_data
|
||||
WHERE datetime >= NOW() - make_interval(days => %s)
|
||||
GROUP BY date_trunc('day', datetime)
|
||||
@@ -516,25 +511,21 @@ async def get_weekly_rain_data(
|
||||
# Bei 365 Tagen: alle verfügbaren Daten zurückgeben
|
||||
if days >= 365:
|
||||
cursor.execute("""
|
||||
SELECT week_start, SUM(daily_max) as total_rain
|
||||
FROM (
|
||||
SELECT date_trunc('week', datetime) as week_start, MAX(rain) as daily_max
|
||||
SELECT
|
||||
date_trunc('week', datetime) as week_start,
|
||||
SUM(rain) as total_rain
|
||||
FROM weather_data
|
||||
GROUP BY date_trunc('week', datetime), DATE(datetime)
|
||||
) sub
|
||||
GROUP BY week_start
|
||||
GROUP BY date_trunc('week', datetime)
|
||||
ORDER BY week_start ASC
|
||||
""")
|
||||
else:
|
||||
cursor.execute("""
|
||||
SELECT week_start, SUM(daily_max) as total_rain
|
||||
FROM (
|
||||
SELECT date_trunc('week', datetime) as week_start, MAX(rain) as daily_max
|
||||
SELECT
|
||||
date_trunc('week', datetime) as week_start,
|
||||
SUM(rain) as total_rain
|
||||
FROM weather_data
|
||||
WHERE datetime >= NOW() - make_interval(days => %s)
|
||||
GROUP BY date_trunc('week', datetime), DATE(datetime)
|
||||
) sub
|
||||
GROUP BY week_start
|
||||
GROUP BY date_trunc('week', datetime)
|
||||
ORDER BY week_start ASC
|
||||
""", (days,))
|
||||
results = cursor.fetchall()
|
||||
@@ -605,7 +596,7 @@ async def get_daily_aggregated_range(
|
||||
MAX(wind_gust * 1.60934)::float as wind_gust,
|
||||
(array_agg(datetime ORDER BY wind_gust DESC NULLS LAST))[1] as max_wind_gust_time,
|
||||
AVG(wind_dir)::float as wind_dir,
|
||||
MAX(rain)::float as total_rain
|
||||
SUM(rain)::float as total_rain
|
||||
FROM weather_data
|
||||
WHERE datetime BETWEEN %s AND %s
|
||||
GROUP BY date_trunc('day', datetime)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "wetterstation-frontend",
|
||||
"private": true,
|
||||
"version": "1.5.7",
|
||||
"version": "1.5.8",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
Reference in New Issue
Block a user