Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
cab9ed705e
|
|||
|
2faa19bc54
|
|||
|
7f52839877
|
@@ -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
|
||||
|
||||
@@ -12,25 +12,17 @@ from app import app
|
||||
from app import oidc
|
||||
|
||||
|
||||
@app.route('/pvstats')
|
||||
@app.route('/')
|
||||
@oidc.require_login
|
||||
def pvstats():
|
||||
try:
|
||||
stepX_time = time.time()
|
||||
dbh = psycopg.connect()
|
||||
engine = sqlalchemy.create_engine("postgresql+psycopg://", creator=lambda: dbh)
|
||||
|
||||
step0_time = time.time()
|
||||
df = pd.read_sql("SELECT month, cast(year AS varchar), current_energy AS value FROM pv_energy_by_month", con=engine)
|
||||
step1_time = time.time()
|
||||
duration1 = step1_time - step0_time
|
||||
logger.info(f"{duration1=}")
|
||||
df = pd.read_sql("SELECT month, cast(year AS varchar), current_energy AS value FROM pv_energy_by_month ORDER BY year, month", con=engine)
|
||||
fig_1 = px.bar(df, x='month', y='value', color='year', barmode='group')
|
||||
step2_time = time.time()
|
||||
duration2 = step2_time - step1_time
|
||||
logger.info(f"{duration2=}")
|
||||
fig_1.update_layout(
|
||||
title=f"Jahreswerte Exportierte Energie {duration1:.3f}, {duration2:.3f}",
|
||||
title=f"Jahreswerte Exportierte Energie PV-Anlage",
|
||||
xaxis_title="",
|
||||
yaxis_title="",
|
||||
legend_title="Jahr",
|
||||
@@ -43,74 +35,34 @@ 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=}")
|
||||
df = pd.read_sql("SELECT month, cast(year AS varchar), current_energy AS value FROM car_energy_by_month ORDER BY year, month", con=engine)
|
||||
fig_2 = px.bar(df, x='month', y='value', color='year', barmode='group')
|
||||
fig_2.update_layout(
|
||||
title=f"Jahreswerte Verbrauch Elektroauto",
|
||||
xaxis_title="",
|
||||
yaxis_title="",
|
||||
title=f"Export gestern {duration3:.3f}, {duration4:.3f}",
|
||||
yaxis=dict(ticksuffix=" W")
|
||||
legend_title="Jahr",
|
||||
xaxis=dict(
|
||||
tickmode="array",
|
||||
tickvals=list(range(1, 13)), # Monate 1–12
|
||||
ticktext=["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"]
|
||||
),
|
||||
yaxis=dict(ticksuffix=" kWh")
|
||||
)
|
||||
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"""
|
||||
<html>
|
||||
<head>
|
||||
<title>Jahreswerte PV-Energie</title>
|
||||
<title>Jahreswerte PV und Auto</title>
|
||||
</head>
|
||||
<body>
|
||||
{graph_html_1}
|
||||
{graph_html_2}
|
||||
{graph_html_3}
|
||||
<div style="height:9vh; background-color:lightgrey; font-family: Courier, Consolas, monospace;">
|
||||
<table style="border-collapse: collapse;">
|
||||
<style>
|
||||
td.smallsep {{ padding-right: 10px }}
|
||||
td.largesep {{ padding-right: 30px }}
|
||||
</style>
|
||||
<tr>
|
||||
<td class="smallsep">Query 1:</td><td class="largesep"> {duration1:.3f} s</td><td class="smallsep">Graph 1:</td><td> {duration2:.3f} s</td>
|
||||
</tr><tr>
|
||||
<td class="smallsep">Query 2:</td><td class="largesep"> {duration3:.3f} s</td><td class="smallsep">Graph 2:</td><td> {duration4:.3f} s</td>
|
||||
</tr><tr>
|
||||
<td class="smallsep">Query 3:</td><td class="largesep"> {duration5:.3f} s</td><td class="smallsep">Graph 3:</td><td> {duration6:.3f} s</td>
|
||||
</tr><tr>
|
||||
<td class="smallsep">Total:</td><td> {duration7:.3f} s</td><td></td><td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
""")
|
||||
except Exception as e:
|
||||
raise Exception(f"Error when querying energy export values: {e}")
|
||||
raise Exception(f"Error when querying energy values: {e}")
|
||||
finally:
|
||||
if dbh is not None:
|
||||
dbh.close()
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user