From d5ec46a3dd1e38790abfb80260c06f735a49c962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Fri, 8 Dec 2023 12:02:46 +0100 Subject: [PATCH] Generate empty leader cards --- main.py | 6 +++--- src/render_site.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 443631a..0ca5287 100644 --- a/main.py +++ b/main.py @@ -13,7 +13,7 @@ import log_setup from log_setup import logger -def subcommand_init(force: bool, fetch_variants: bool): +def subcommand_init(force: bool, no_fetch_variants: bool): tables = database.get_existing_tables() if len(tables) > 0 and not force: logger.info( @@ -31,7 +31,7 @@ def subcommand_init(force: bool, fetch_variants: bool): return database.init_database() logger.info("Successfully initialized database tables") - if fetch_variants: + if not no_fetch_variants: database.fetch_and_initialize_variants() database.initialize_variant_base_ratings() logger.info("Successfully initialized variants and base ratings.") @@ -53,7 +53,7 @@ def get_parser() -> argparse.ArgumentParser: init_parser = subparsers.add_parser('init', help='Initialize database.') init_parser.add_argument('--force', '-f', help='Force initialization (Drops existing tables)', action='store_true') - init_parser.add_argument('--no-fetch-variants', '-n', help='Do not fetch and initialize variants', action='store_false') + init_parser.add_argument('--no-fetch-variants', '-n', help='Do not fetch and initialize variants', action='store_true') subparsers.add_parser('generate-config', help='Generate config file at default location') diff --git a/src/render_site.py b/src/render_site.py index d7fcba2..23e2e03 100644 --- a/src/render_site.py +++ b/src/render_site.py @@ -219,12 +219,20 @@ def get_leaders(rating_lists: Dict, streak_lists: Dict) -> Dict[int, Dict[str, L leaders[rating_type] = { 'Player Rating': Leader('Highest Rating', utils.describe_rating_type(rating_type), leader) } + else: + leaders[rating_type] = { + 'Player Rating': Leader('Highest Rating', utils.describe_rating_type(rating_type), PlayerEntry('-', '', 0)) + } for rating_type, streak_list in streak_lists.items(): if len(streak_list) != 0: leader = streak_list[0] if rating_type not in leaders.keys(): leaders[rating_type] = {} leaders[rating_type]['Top Streak'] = Leader('Longest Win Streak', utils.describe_rating_type(rating_type), leader) + else: + leaders[rating_type]['Top Streak'] = \ + Leader('Longest Win Streak', utils.describe_rating_type(rating_type), PlayerEntry('-', '', 0)) + return leaders @@ -393,5 +401,7 @@ def render_leaderboard(): # Copy CSS to output directory shutil.copytree('css', 'build/css', dirs_exist_ok=True) + shutil.copytree('deps/tabulator/dist/css', 'build/css', dirs_exist_ok=True) + shutil.copytree('deps/tabulator/dist/js', 'build/js', dirs_exist_ok=True) render_leaderboard()