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