Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
e3b2ea704d | |||
8bd4a4b695 | |||
89f3cbb5d1 | |||
37c4a373b7 | |||
408cff442c | |||
67b88aa2a1 | |||
7b0238b4a5 | |||
16771227bb | |||
aa97e3cdd3 | |||
2c93c7ec47 | |||
e0b1c469d2 |
@ -20,7 +20,7 @@ steps:
|
|||||||
when:
|
when:
|
||||||
- event: [push, tag]
|
- event: [push, tag]
|
||||||
deploy:
|
deploy:
|
||||||
image: quay.io/wollud1969/k8s-admin-helper:0.1.3
|
image: quay.io/wollud1969/k8s-admin-helper:0.2.1
|
||||||
environment:
|
environment:
|
||||||
KUBE_CONFIG_CONTENT:
|
KUBE_CONFIG_CONTENT:
|
||||||
from_secret: kube_config
|
from_secret: kube_config
|
||||||
|
@ -4,6 +4,8 @@ metadata:
|
|||||||
name: pv-stats
|
name: pv-stats
|
||||||
labels:
|
labels:
|
||||||
app: pv-stats
|
app: pv-stats
|
||||||
|
annotations:
|
||||||
|
secret.reloader.stakater.com/reload: pv-stats
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
replicas: 1
|
||||||
selector:
|
selector:
|
||||||
|
@ -19,10 +19,11 @@ kubectl create namespace $NAMESPACE \
|
|||||||
-o yaml | \
|
-o yaml | \
|
||||||
kubectl -f - apply
|
kubectl -f - apply
|
||||||
|
|
||||||
SECRETS_FILE=`mktemp`
|
# SECRETS_FILE=`mktemp`
|
||||||
gpg --decrypt --passphrase $GPG_PASSPHRASE --yes --batch --homedir /tmp/.gnupg --output $SECRETS_FILE secrets.asc
|
# gpg --decrypt --passphrase $GPG_PASSPHRASE --yes --batch --homedir /tmp/.gnupg --output $SECRETS_FILE secrets.asc
|
||||||
. $SECRETS_FILE
|
# . $SECRETS_FILE
|
||||||
rm $SECRETS_FILE
|
# rm $SECRETS_FILE
|
||||||
|
eval "`cat secrets.asc | /usr/local/bin/decrypt-secrets.sh`"
|
||||||
|
|
||||||
kubectl create secret generic pv-stats \
|
kubectl create secret generic pv-stats \
|
||||||
--dry-run=client \
|
--dry-run=client \
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
-----BEGIN PGP MESSAGE-----
|
-----BEGIN PGP MESSAGE-----
|
||||||
|
|
||||||
jA0ECQMCjSYtdE7M+rT/0sEmAbK6tjOB7cduweJyS3sULIl017BrOM1HGV1v4QkN
|
jA0ECQMC4tvOFCp2PT7/0sE+AcZmiGwroHYdWW/vJA1sCoMrM2oW8xUc1KndDGto
|
||||||
NWtceKHpJEFmk1ZFh1EmyS724bDxtVLm8qJN4VzV+cLPa8/IiTzOHJEg4PDRcc0U
|
dFev2KcoZ4FRL9liCrJ7on773bZFCTDu2xiBNMeKF1p8drub1Ej5l61Oq15mLTYf
|
||||||
LRCZOb5PtfKWBcQdRshT3JhIxxOKG53ZKOHJ2VodZ/iqmpSbjZ39GtzLJoXlXwCJ
|
XjXknFiWWq4PTzhhy53zvDyIV5yIcGfjotpGC83/qH5CBWIcCw9PZHI5+uHRVRKL
|
||||||
jHAHgADdvq5J7joSaozjxVCXQI2nOmlEcZosZVd6LZDvemWtmci4ARJtOEqad4Wi
|
OpdTpekJ8ljPAGQ4F3vbOeBbG1PMoclx8r5SpKxLwQco2iaXd71dXHtPkEnLujd4
|
||||||
mbleupBF18pA7b63hfmHocO89b9pTpUZWw10b0SHrUiKZG6kHeQXE8GGu+4HiRcG
|
ZRCthVNVfxrIIRcTJfgxewz2oJWYF9008nmtxpKzqfBtNpFIdBtnTTVvv2lfcVuS
|
||||||
xJN/yYe2Ly4tHwT54gQ7ytLrxOnJUQKelSpq370t/lrGTf8L4b2eq+tED8/7z5Ho
|
S4eav9ljPPd/exZaT7fOGD/kuCdiiu6e0yGLzo2ykf0uBy7hG7ZJg8TH5e+LMBm9
|
||||||
E12VDreYLFaS2IeJCFBefiGGbKgttPcHZvDCPCUpCpfSShlqtTaidwsTq2lPFGyo
|
Q1OFD+5LWeEsOEdSTlT5UbV5EaVEiawKWQn7rMZOyvBNiPwLaOlquHirWoll5eIm
|
||||||
0Lz9NHsqp4/U+4nabCWNVWhnZhwqIPYOt/kKsYvjq40U29q7RORnxz8l/Ym4vB1P
|
OHgBVN0FiY/righpIoei/KP705FIg+hrpMUvc29PahiL8dgsxJycnKIo4t+2/nac
|
||||||
kLeouElJvAz6vt/1+nFQJb65YykTqKQpbKgbziFiUFwb37QzBqRO7tuv3/MUzJ1Q
|
H144hP/rqBeaobG05TkZIr+Cpt4rpwwfNWOHgmNFHVpxdmPfoeAmpT4nz760hTEN
|
||||||
KB7+IOQ43vFbAK6DZAhJZtAspVYiZ95niVxepaghzf33/FquhtZ+XpFEBDv525z7
|
2ol4Qh8xL7n4GFiCpNg8tNZiZkPPa/aRUAFxgdq5beossvKukxCexQmlCFvxITSG
|
||||||
pML7BxFxuwF5q7HBTPtc4IeJBgGi16wm
|
x9RwssFMnT+wqTuzBN8neBeEF1d9AtAFQKPtg3wkMUyJAlYkxiGS/2NJuYDVpmEQ
|
||||||
=K6Qq
|
=Wr4f
|
||||||
-----END PGP MESSAGE-----
|
-----END PGP MESSAGE-----
|
||||||
|
32
src/run.py
32
src/run.py
@ -10,6 +10,7 @@ import plotly.express as px
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
import psycopg
|
import psycopg
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
import time
|
||||||
|
|
||||||
try:
|
try:
|
||||||
redis_url = os.environ['REDIS_URL']
|
redis_url = os.environ['REDIS_URL']
|
||||||
@ -39,19 +40,27 @@ oidc = OpenIDConnect(app)
|
|||||||
def token_debug():
|
def token_debug():
|
||||||
# Access Token vom Identity Provider abrufen
|
# Access Token vom Identity Provider abrufen
|
||||||
access_token = oidc.get_access_token()
|
access_token = oidc.get_access_token()
|
||||||
return jsonify({"access_token": access_token})
|
return json.dumps({
|
||||||
|
"access_token": access_token
|
||||||
|
})
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
@oidc.require_login
|
@oidc.require_login
|
||||||
def index():
|
def index():
|
||||||
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
|
||||||
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
|
||||||
fig_1.update_layout(
|
fig_1.update_layout(
|
||||||
title="Jahreswerte Exportierte Energie",
|
title=f"Jahreswerte Exportierte Energie {duration1:.3f}, {duration2:.3f}",
|
||||||
xaxis_title="",
|
xaxis_title="",
|
||||||
yaxis_title="",
|
yaxis_title="",
|
||||||
legend_title="Jahr",
|
legend_title="Jahr",
|
||||||
@ -64,25 +73,37 @@ def index():
|
|||||||
)
|
)
|
||||||
graph_html_1 = fig_1.to_html(full_html=False, default_height='33%')
|
graph_html_1 = fig_1.to_html(full_html=False, default_height='33%')
|
||||||
|
|
||||||
|
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)
|
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()
|
||||||
|
duration1 = step4_time - step3_time
|
||||||
fig_2 = px.line(df, x='bucket', y='avg_power')
|
fig_2 = px.line(df, x='bucket', y='avg_power')
|
||||||
|
step5_time = time.time()
|
||||||
|
duration2 = step5_time - step4_time
|
||||||
fig_2.update_layout(
|
fig_2.update_layout(
|
||||||
xaxis_title="",
|
xaxis_title="",
|
||||||
yaxis_title="",
|
yaxis_title="",
|
||||||
title="Export gestern",
|
title=f"Export gestern {duration1:.3f}, {duration2:.3f}",
|
||||||
yaxis=dict(ticksuffix=" W")
|
yaxis=dict(ticksuffix=" W")
|
||||||
)
|
)
|
||||||
graph_html_2 = fig_2.to_html(full_html=False, default_height='33%')
|
graph_html_2 = fig_2.to_html(full_html=False, default_height='33%')
|
||||||
|
|
||||||
|
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)
|
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()
|
||||||
|
duration1 = step7_time - step6_time
|
||||||
fig_3 = px.line(df, x='bucket', y='avg_power')
|
fig_3 = px.line(df, x='bucket', y='avg_power')
|
||||||
|
step8_time = time.time()
|
||||||
|
duration2 = step8_time - step7_time
|
||||||
fig_3.update_layout(
|
fig_3.update_layout(
|
||||||
xaxis_title="",
|
xaxis_title="",
|
||||||
yaxis_title="",
|
yaxis_title="",
|
||||||
title="Export heute",
|
title=f"Export heute {duration1:.3f}, {duration2:.3f}",
|
||||||
yaxis=dict(ticksuffix=" W")
|
yaxis=dict(ticksuffix=" W")
|
||||||
)
|
)
|
||||||
graph_html_3 = fig_3.to_html(full_html=False, default_height='33%')
|
graph_html_3 = fig_3.to_html(full_html=False, default_height='33%')
|
||||||
|
stepZ_time = time.time()
|
||||||
|
duration = stepZ_time - stepX_time
|
||||||
|
|
||||||
return render_template_string(f"""
|
return render_template_string(f"""
|
||||||
<html>
|
<html>
|
||||||
@ -93,6 +114,9 @@ def index():
|
|||||||
{graph_html_1}
|
{graph_html_1}
|
||||||
{graph_html_2}
|
{graph_html_2}
|
||||||
{graph_html_3}
|
{graph_html_3}
|
||||||
|
<p>
|
||||||
|
{duration:.3f}
|
||||||
|
</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
""")
|
""")
|
||||||
|
Reference in New Issue
Block a user