Compare commits

...

2 Commits

Author SHA1 Message Date
simon 39999f5128
delay monthly recreation from app startup 2023-03-27 10:36:37 +07:00
simon ee61496ecb
fix key map for out of index matches 2023-03-27 10:04:32 +07:00
2 changed files with 10 additions and 5 deletions

View File

@ -92,7 +92,11 @@ def chart_fill(plt, y_ticks):
} }
for tick in y_ticks[0:-1]: for tick in y_ticks[0:-1]:
match = key_map[tick] if tick > 300:
match = key_map[300]
else:
match = key_map[tick]
plt.axhspan( plt.axhspan(
match["low"], match["high"], facecolor=match["color"], zorder=0 match["low"], match["high"], facecolor=match["color"], zorder=0
) )

View File

@ -1,7 +1,7 @@
""" main entry page to handle all the routes """ """ main entry page to handle all the routes """
import os import os
from datetime import datetime from datetime import datetime, timedelta
from flask import Flask, render_template, request, app from flask import Flask, render_template, request, app
from flask import url_for # pylint: disable=unused-import from flask import url_for # pylint: disable=unused-import
@ -51,11 +51,9 @@ if not is_maintenance_mode:
print('initial export') print('initial export')
current_graph() current_graph()
nightly_graph() nightly_graph()
monthly_graph()
# start scheduler # start scheduler
timezone = os.environ.get("TZ") scheduler = BackgroundScheduler(timezone=os.environ.get("TZ", "UTC"))
scheduler = BackgroundScheduler(timezone=timezone)
scheduler.add_job( scheduler.add_job(
current_graph, trigger="cron", minute='*/5', name='current_graph' current_graph, trigger="cron", minute='*/5', name='current_graph'
) )
@ -65,6 +63,9 @@ if not is_maintenance_mode:
scheduler.add_job( scheduler.add_job(
monthly_graph, trigger="cron", day='*', hour='1', minute='2', name='month' monthly_graph, trigger="cron", day='*', hour='1', minute='2', name='month'
) )
scheduler.add_job(
monthly_graph, next_run_time=datetime.now() + timedelta(seconds=10)
)
scheduler.start() scheduler.start()