From 85130f2bbd493679246897614092d30ae4f7f736 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Tue, 1 Nov 2022 23:01:53 +0100 Subject: [PATCH] WebHost: update modules (#1176) Fix bokeh 3.0.0 attribute removal and touch up stats.py while at it --- WebHostLib/requirements.txt | 6 +++--- WebHostLib/stats.py | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/WebHostLib/requirements.txt b/WebHostLib/requirements.txt index a4dd710e..89972531 100644 --- a/WebHostLib/requirements.txt +++ b/WebHostLib/requirements.txt @@ -2,6 +2,6 @@ flask>=2.2.2 pony>=0.7.16 waitress>=2.1.2 Flask-Caching>=2.0.1 -Flask-Compress>=1.12 -Flask-Limiter>=2.6.2 -bokeh>=2.4.3 +Flask-Compress>=1.13 +Flask-Limiter>=2.7.0 +bokeh>=3.0.0 diff --git a/WebHostLib/stats.py b/WebHostLib/stats.py index e30ac820..c624163e 100644 --- a/WebHostLib/stats.py +++ b/WebHostLib/stats.py @@ -18,7 +18,8 @@ from .models import Room PLOT_WIDTH = 600 -def get_db_data(known_games: str) -> typing.Tuple[typing.Dict[str, int], typing.Dict[datetime.date, typing.Dict[str, int]]]: +def get_db_data(known_games: typing.Set[str]) -> typing.Tuple[typing.Counter[str], + typing.DefaultDict[datetime.date, typing.Dict[str, int]]]: games_played = defaultdict(Counter) total_games = Counter() cutoff = date.today()-timedelta(days=30) @@ -93,7 +94,7 @@ def stats(): occurences, legend_label=game, line_width=2, color=game_to_color[game]) total = sum(total_games.values()) - pie = figure(plot_height=350, title=f"Games Played in the Last 30 Days (Total: {total})", toolbar_location=None, + pie = figure(title=f"Games Played in the Last 30 Days (Total: {total})", toolbar_location=None, tools="hover", tooltips=[("Game:", "@games"), ("Played:", "@count")], sizing_mode="scale_both", width=PLOT_WIDTH, height=500, x_range=(-0.5, 1.2)) pie.axis.visible = False @@ -121,7 +122,8 @@ def stats(): start_angle="start_angles", end_angle="end_angles", fill_color="colors", source=ColumnDataSource(data=data), legend_field="games") - per_game_charts = [create_game_played_figure(games_played, game, game_to_color[game]) for game in total_games + per_game_charts = [create_game_played_figure(games_played, game, game_to_color[game]) for game in + sorted(total_games, key=lambda game: total_games[game]) if total_games[game] > 1] script, charts = components((plot, pie, *per_game_charts))