Generate empty leader cards

This commit is contained in:
Maximilian Keßler 2023-12-08 12:02:46 +01:00
parent 459cdee108
commit d5ec46a3dd
Signed by: max
GPG key ID: BCC5A619923C0BA5
2 changed files with 13 additions and 3 deletions

View file

@ -13,7 +13,7 @@ import log_setup
from log_setup import logger 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() tables = database.get_existing_tables()
if len(tables) > 0 and not force: if len(tables) > 0 and not force:
logger.info( logger.info(
@ -31,7 +31,7 @@ def subcommand_init(force: bool, fetch_variants: bool):
return return
database.init_database() database.init_database()
logger.info("Successfully initialized database tables") logger.info("Successfully initialized database tables")
if fetch_variants: if not no_fetch_variants:
database.fetch_and_initialize_variants() database.fetch_and_initialize_variants()
database.initialize_variant_base_ratings() database.initialize_variant_base_ratings()
logger.info("Successfully initialized variants and 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 = 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('--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') subparsers.add_parser('generate-config', help='Generate config file at default location')

View file

@ -219,12 +219,20 @@ def get_leaders(rating_lists: Dict, streak_lists: Dict) -> Dict[int, Dict[str, L
leaders[rating_type] = { leaders[rating_type] = {
'Player Rating': Leader('Highest Rating', utils.describe_rating_type(rating_type), leader) '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(): for rating_type, streak_list in streak_lists.items():
if len(streak_list) != 0: if len(streak_list) != 0:
leader = streak_list[0] leader = streak_list[0]
if rating_type not in leaders.keys(): if rating_type not in leaders.keys():
leaders[rating_type] = {} leaders[rating_type] = {}
leaders[rating_type]['Top Streak'] = Leader('Longest Win Streak', utils.describe_rating_type(rating_type), leader) 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 return leaders
@ -393,5 +401,7 @@ def render_leaderboard():
# Copy CSS to output directory # Copy CSS to output directory
shutil.copytree('css', 'build/css', dirs_exist_ok=True) 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() render_leaderboard()