Compare commits
2 Commits
bd804f1464
...
162a77d31a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
162a77d31a | ||
|
|
c75e11204a |
31
wsgi.py
31
wsgi.py
@ -191,7 +191,11 @@ def plot(
|
|||||||
|
|
||||||
return fig
|
return fig
|
||||||
|
|
||||||
def create_fig(url: str = "https://beschaeftigtenbefragung.verdi.de/", importance_factor: float = 1.0):
|
|
||||||
|
def create_fig(
|
||||||
|
url: str = "https://beschaeftigtenbefragung.verdi.de/",
|
||||||
|
importance_factor: float = 1.0,
|
||||||
|
):
|
||||||
curr_datetime = datetime.datetime.now()
|
curr_datetime = datetime.datetime.now()
|
||||||
try:
|
try:
|
||||||
df, df_state = get_tables(url)
|
df, df_state = get_tables(url)
|
||||||
@ -231,12 +235,17 @@ def create_fig(url: str = "https://beschaeftigtenbefragung.verdi.de/", importanc
|
|||||||
for bez in plot_df.columns
|
for bez in plot_df.columns
|
||||||
if plot_df.loc[curr_datetime][bez] >= importance_factor * total
|
if plot_df.loc[curr_datetime][bez] >= importance_factor * total
|
||||||
]
|
]
|
||||||
return plot(
|
return (
|
||||||
curr_datetime,
|
plot(
|
||||||
plot_df,
|
curr_datetime,
|
||||||
annotate_current=annotate_current,
|
plot_df,
|
||||||
landesbez_str=landesbez_strs,
|
annotate_current=annotate_current,
|
||||||
), df, df_state, timestamp
|
landesbez_str=landesbez_strs,
|
||||||
|
),
|
||||||
|
df,
|
||||||
|
df_state,
|
||||||
|
timestamp,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def convert_fig_to_svg(fig: plt.Figure) -> str:
|
def convert_fig_to_svg(fig: plt.Figure) -> str:
|
||||||
@ -249,7 +258,7 @@ def convert_fig_to_svg(fig: plt.Figure) -> str:
|
|||||||
|
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
@cache.cached()
|
@cache.cached(query_string=True)
|
||||||
def tables():
|
def tables():
|
||||||
def _print_as_html(df: pd.DataFrame):
|
def _print_as_html(df: pd.DataFrame):
|
||||||
df = df.astype({"Digitale Befragung": "Int32"})
|
df = df.astype({"Digitale Befragung": "Int32"})
|
||||||
@ -281,9 +290,13 @@ def tables():
|
|||||||
output_str.append(tfoot)
|
output_str.append(tfoot)
|
||||||
output_str.append(table[idx:])
|
output_str.append(table[idx:])
|
||||||
|
|
||||||
|
importance_factor = float(request.args.get("importance"))
|
||||||
|
if not importance_factor:
|
||||||
|
importance_factor = 1.0
|
||||||
|
|
||||||
output_str = []
|
output_str = []
|
||||||
|
|
||||||
fig, df, df_state, timestamp = create_fig()
|
fig, df, df_state, timestamp = create_fig(importance_factor=importance_factor)
|
||||||
svg_string = convert_fig_to_svg(fig)
|
svg_string = convert_fig_to_svg(fig)
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user