From 7f5283987739717c23c6e4b517bf76b1198bf45b Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Mon, 15 Dec 2025 18:01:49 +0100 Subject: [PATCH] stats --- .woodpecker.yml | 14 ++++++------ src/pv_routes.py | 58 +----------------------------------------------- src/routes.py | 4 ---- 3 files changed, 8 insertions(+), 68 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 5ab9233..5d2fa14 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -4,15 +4,15 @@ steps: settings: repo: ${FORGE_NAME}/${CI_REPO} registry: - from_secret: container_registry - tags: latest,${CI_COMMIT_SHA},${CI_COMMIT_TAG} + from_secret: local_registry + tags: latest,${CI_COMMIT_TAG} username: - from_secret: container_registry_username + from_secret: local_username password: - from_secret: container_registry_password + from_secret: local_password dockerfile: Dockerfile when: - - event: [push, tag] + - event: tag scan: image: quay.io/wollud1969/woodpecker-helper:0.5.1 @@ -27,7 +27,7 @@ steps: from_secret: dtrack_api_url commands: - HOME=/home/`id -nu` - - TAG="${CI_COMMIT_TAG:-$CI_COMMIT_SHA}" + - TAG="${CI_COMMIT_TAG}" - | trivy image \ --server $TRIVY_URL \ @@ -50,7 +50,7 @@ steps: - event: [push, tag] deploy: - image: quay.io/wollud1969/k8s-admin-helper:0.2.1 + image: quay.io/wollud1969/k8s-admin-helper:0.4.1 environment: KUBE_CONFIG_CONTENT: from_secret: kube_config diff --git a/src/pv_routes.py b/src/pv_routes.py index a642843..c4da400 100644 --- a/src/pv_routes.py +++ b/src/pv_routes.py @@ -12,7 +12,7 @@ from app import app from app import oidc -@app.route('/pvstats') +@app.route('/') @oidc.require_login def pvstats(): try: @@ -43,43 +43,6 @@ def pvstats(): ) graph_html_1 = fig_1.to_html(full_html=False, default_height='30%') - step3_time = time.time() - df = pd.read_sql("SELECT time_bucket('5 minutes', time) AS bucket, AVG(power) AS avg_power FROM pv_power_v WHERE time >= date_trunc('day', now()) - '1 day'::interval AND time < date_trunc('day', now()) GROUP BY bucket ORDER BY bucket", con=engine) - step4_time = time.time() - duration3 = step4_time - step3_time - logger.info(f"{duration3=}") - fig_2 = px.line(df, x='bucket', y='avg_power') - step5_time = time.time() - duration4 = step5_time - step4_time - logger.info(f"{duration4=}") - fig_2.update_layout( - xaxis_title="", - yaxis_title="", - title=f"Export gestern {duration3:.3f}, {duration4:.3f}", - yaxis=dict(ticksuffix=" W") - ) - graph_html_2 = fig_2.to_html(full_html=False, default_height='30%') - - step6_time = time.time() - df = pd.read_sql("SELECT time_bucket('5 minutes', time) AS bucket, AVG(power) AS avg_power FROM pv_power_v WHERE time >= date_trunc('day', now()) AND time < date_trunc('day', now()) + '1 day'::interval GROUP BY bucket ORDER BY bucket", con=engine) - step7_time = time.time() - duration5 = step7_time - step6_time - logger.info(f"{duration5=}") - fig_3 = px.line(df, x='bucket', y='avg_power') - step8_time = time.time() - duration6 = step8_time - step7_time - logger.info(f"{duration6=}") - fig_3.update_layout( - xaxis_title="", - yaxis_title="", - title=f"Export heute {duration5:.3f}, {duration6:.3f}", - yaxis=dict(ticksuffix=" W") - ) - graph_html_3 = fig_3.to_html(full_html=False, default_height='30%') - stepZ_time = time.time() - duration7 = stepZ_time - stepX_time - logger.info(f"{duration7=}") - return render_template_string(f""" @@ -87,25 +50,6 @@ def pvstats(): {graph_html_1} - {graph_html_2} - {graph_html_3} -
- - - - - - - - - - - -
Query 1: {duration1:.3f} sGraph 1: {duration2:.3f} s
Query 2: {duration3:.3f} sGraph 2: {duration4:.3f} s
Query 3: {duration5:.3f} sGraph 3: {duration6:.3f} s
Total: {duration7:.3f} s
-
""") diff --git a/src/routes.py b/src/routes.py index 2656d25..7532d8c 100644 --- a/src/routes.py +++ b/src/routes.py @@ -5,10 +5,6 @@ from app import app from app import oidc -@app.route('/') -def index(): - abort(404) - @app.route('/generate_image') def generate_image(): img = Image.new('RGB', (200, 100), color=(255, 255, 255))