Refactor
This commit is contained in:
parent
0292db36e2
commit
dbf477ed17
17
wsgi.py
17
wsgi.py
@ -257,10 +257,7 @@ def convert_fig_to_svg(fig: plt.Figure) -> str:
|
||||
return imgdata.read()
|
||||
|
||||
|
||||
@app.route("/")
|
||||
@cache.cached(query_string=True)
|
||||
def tables():
|
||||
def _print_as_html(df: pd.DataFrame, total: int | None = None) -> None:
|
||||
def _print_as_html(df: pd.DataFrame, output_str: list[str], total: int | None = None) -> list[str]:
|
||||
df = df.astype({"Digitale Befragung": "Int32"})
|
||||
df = df.dropna()
|
||||
with pd.option_context("display.max_rows", None):
|
||||
@ -304,26 +301,28 @@ def tables():
|
||||
output_str.append(table[: idx - 1])
|
||||
output_str.append(tfoot)
|
||||
output_str.append(table[idx:])
|
||||
return output_str
|
||||
|
||||
|
||||
@app.route("/")
|
||||
@cache.cached(query_string=True)
|
||||
def tables():
|
||||
importance_factor = request.args.get("importance")
|
||||
if not importance_factor:
|
||||
importance_factor = 1.0
|
||||
else:
|
||||
importance_factor = float(importance_factor)
|
||||
|
||||
output_str = []
|
||||
|
||||
fig, df, df_state, timestamp = create_fig(importance_factor=importance_factor)
|
||||
svg_string = convert_fig_to_svg(fig)
|
||||
plt.close()
|
||||
|
||||
_print_as_html(df_state)
|
||||
|
||||
df["Bundesland"] = df.index.map(get_landesbezirk)
|
||||
df = df.rename(columns={"Bundesland": "Landesbezirk"})
|
||||
|
||||
_print_as_html(df, total=df_state['Digitale Befragung'].sum())
|
||||
output_str = []
|
||||
output_str = _print_as_html(df_state, output_str)
|
||||
output_str = _print_as_html(df, output_str, total=df_state['Digitale Befragung'].sum())
|
||||
|
||||
return render_template(
|
||||
"base.html",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user