This commit is contained in:
2025-05-13 04:34:23 +02:00
parent 5081df993f
commit 37c2ba9052
3 changed files with 134 additions and 113 deletions

7
app.py
View File

@@ -25,6 +25,7 @@ def load_data():
def get_aggregated_data(df: pd.DataFrame, interval: str = '5min'):
# ensure 'datetime' is the index
df = df.set_index('datetime')
@@ -41,7 +42,7 @@ def get_aggregated_data(df: pd.DataFrame, interval: str = '5min'):
# 3) output for Chart.js
return {
"times": agg['recorded_at'].tolist(),
"times": agg['datetime'].tolist(),
"down_90th": agg['down_90th'].round(2).tolist(),
"up_90th": agg['up_90th'].round(2).tolist()
}
@@ -53,10 +54,6 @@ def index():
agg = request.args.get("agg", "5min")
chart_data = get_aggregated_data(df, agg)
print(f"down last 10: {chart_data['down_90th'][-10:]}")
print(f"down last 10: {chart_data['up_90th'][-10:]}")
print(math.isnan(chart_data['down_90th'][-1]) or math.isnan(chart_data['up_90th'][-1]))
#if math.isnan(chart_data['down_90th'][-1]) or math.isnan(chart_data['up_90th'][-1]):
#return render_template('local.html', data=df.to_dict(orient='records'), chart_data=chart_data)