Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
2faa19bc54
|
|||
|
7f52839877
|
@@ -4,15 +4,15 @@ steps:
|
|||||||
settings:
|
settings:
|
||||||
repo: ${FORGE_NAME}/${CI_REPO}
|
repo: ${FORGE_NAME}/${CI_REPO}
|
||||||
registry:
|
registry:
|
||||||
from_secret: container_registry
|
from_secret: local_registry
|
||||||
tags: latest,${CI_COMMIT_SHA},${CI_COMMIT_TAG}
|
tags: latest,${CI_COMMIT_TAG}
|
||||||
username:
|
username:
|
||||||
from_secret: container_registry_username
|
from_secret: local_username
|
||||||
password:
|
password:
|
||||||
from_secret: container_registry_password
|
from_secret: local_password
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
when:
|
when:
|
||||||
- event: [push, tag]
|
- event: tag
|
||||||
|
|
||||||
scan:
|
scan:
|
||||||
image: quay.io/wollud1969/woodpecker-helper:0.5.1
|
image: quay.io/wollud1969/woodpecker-helper:0.5.1
|
||||||
@@ -27,7 +27,7 @@ steps:
|
|||||||
from_secret: dtrack_api_url
|
from_secret: dtrack_api_url
|
||||||
commands:
|
commands:
|
||||||
- HOME=/home/`id -nu`
|
- HOME=/home/`id -nu`
|
||||||
- TAG="${CI_COMMIT_TAG:-$CI_COMMIT_SHA}"
|
- TAG="${CI_COMMIT_TAG}"
|
||||||
- |
|
- |
|
||||||
trivy image \
|
trivy image \
|
||||||
--server $TRIVY_URL \
|
--server $TRIVY_URL \
|
||||||
@@ -50,7 +50,7 @@ steps:
|
|||||||
- event: [push, tag]
|
- event: [push, tag]
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
image: quay.io/wollud1969/k8s-admin-helper:0.2.1
|
image: quay.io/wollud1969/k8s-admin-helper:0.4.1
|
||||||
environment:
|
environment:
|
||||||
KUBE_CONFIG_CONTENT:
|
KUBE_CONFIG_CONTENT:
|
||||||
from_secret: kube_config
|
from_secret: kube_config
|
||||||
|
|||||||
@@ -12,25 +12,17 @@ from app import app
|
|||||||
from app import oidc
|
from app import oidc
|
||||||
|
|
||||||
|
|
||||||
@app.route('/pvstats')
|
@app.route('/')
|
||||||
@oidc.require_login
|
@oidc.require_login
|
||||||
def pvstats():
|
def pvstats():
|
||||||
try:
|
try:
|
||||||
stepX_time = time.time()
|
|
||||||
dbh = psycopg.connect()
|
dbh = psycopg.connect()
|
||||||
engine = sqlalchemy.create_engine("postgresql+psycopg://", creator=lambda: dbh)
|
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)
|
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=}")
|
|
||||||
fig_1 = px.bar(df, x='month', y='value', color='year', barmode='group')
|
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(
|
fig_1.update_layout(
|
||||||
title=f"Jahreswerte Exportierte Energie {duration1:.3f}, {duration2:.3f}",
|
title=f"Jahreswerte Exportierte Energie PV-Anlage",
|
||||||
xaxis_title="",
|
xaxis_title="",
|
||||||
yaxis_title="",
|
yaxis_title="",
|
||||||
legend_title="Jahr",
|
legend_title="Jahr",
|
||||||
@@ -43,74 +35,34 @@ def pvstats():
|
|||||||
)
|
)
|
||||||
graph_html_1 = fig_1.to_html(full_html=False, default_height='30%')
|
graph_html_1 = fig_1.to_html(full_html=False, default_height='30%')
|
||||||
|
|
||||||
step3_time = time.time()
|
df = pd.read_sql("SELECT month, cast(year AS varchar), current_energy AS value FROM car_energy_by_month", con=engine)
|
||||||
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)
|
fig_2 = px.bar(df, x='month', y='value', color='year', barmode='group')
|
||||||
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(
|
fig_2.update_layout(
|
||||||
|
title=f"Jahreswerte Verbrauch Elektroauto",
|
||||||
xaxis_title="",
|
xaxis_title="",
|
||||||
yaxis_title="",
|
yaxis_title="",
|
||||||
title=f"Export gestern {duration3:.3f}, {duration4:.3f}",
|
legend_title="Jahr",
|
||||||
yaxis=dict(ticksuffix=" W")
|
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%')
|
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"""
|
return render_template_string(f"""
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Jahreswerte PV-Energie</title>
|
<title>Jahreswerte PV und Auto</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{graph_html_1}
|
{graph_html_1}
|
||||||
{graph_html_2}
|
{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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
""")
|
""")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise Exception(f"Error when querying energy export values: {e}")
|
raise Exception(f"Error when querying energy values: {e}")
|
||||||
finally:
|
finally:
|
||||||
if dbh is not None:
|
if dbh is not None:
|
||||||
dbh.close()
|
dbh.close()
|
||||||
|
|||||||
@@ -5,10 +5,6 @@ from app import app
|
|||||||
from app import oidc
|
from app import oidc
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
|
||||||
def index():
|
|
||||||
abort(404)
|
|
||||||
|
|
||||||
@app.route('/generate_image')
|
@app.route('/generate_image')
|
||||||
def generate_image():
|
def generate_image():
|
||||||
img = Image.new('RGB', (200, 100), color=(255, 255, 255))
|
img = Image.new('RGB', (200, 100), color=(255, 255, 255))
|
||||||
|
|||||||
Reference in New Issue
Block a user