move leader cards to summary page

This commit is contained in:
Maximilian Keßler 2023-12-04 23:49:42 +01:00
parent 0b67cea089
commit 55148c48ab
Signed by: max
GPG key ID: BCC5A619923C0BA5
4 changed files with 37 additions and 15 deletions

View file

@ -1,11 +1,14 @@
.player-name {
font-size: 1.25rem;
font-size: 1.5rem;
font-weight: bold;
}
.alt-name {
font-size: 0.75rem;
color: #777;
}
.leaderboard-category {
font-size: 1.25rem;
}
.score {
font-size: 1.5rem;
font-weight: bold;

View file

@ -1,6 +1,9 @@
import shutil
from pathlib import Path
from typing import Dict, List
import subprocess
import jinja2
import datetime
import psycopg2.extras
@ -28,6 +31,7 @@ class PlayerStreakEntry(PlayerEntry):
@dataclass
class Leader:
title: str
category: str
entry: PlayerEntry
@ -112,14 +116,14 @@ def get_leaders(rating_lists: Dict, streak_lists: Dict) -> Dict[int, Dict[str, L
if len(rating_list) != 0:
leader = rating_list[0]
leaders[rating_type] = {
'Player Rating': Leader('Highest Rating', leader)
'Player Rating': Leader('Highest Rating', utils.describe_rating_type(rating_type), leader)
}
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', leader)
leaders[rating_type]['Top Streak'] = Leader('Longest Win Streak', utils.describe_rating_type(rating_type), leader)
return leaders
@ -254,7 +258,9 @@ def render_leaderboard():
# variants=variants,
)
output_file = Path(constants.WEBSITE_OUTPUT_DIRECTORY) / 'index.html'
out_dir = Path(constants.WEBSITE_OUTPUT_DIRECTORY)
output_file = out_dir / 'index.html'
output_file.parent.mkdir(exist_ok=True, parents=True)
with open(output_file, 'w') as f:
f.write(rendered_html)
@ -269,11 +275,14 @@ def render_leaderboard():
variant_name=variant_names[variant_id]
)
output_file = Path(constants.WEBSITE_OUTPUT_DIRECTORY) / 'variant' / str(variant_id) / 'index.html'
output_file = out_dir / 'variant' / str(variant_id) / 'index.html'
output_file.parent.mkdir(exist_ok=True, parents=True)
with open(output_file, 'w') as f:
f.write(rendered_var)
# Copy CSS to output directory
shutil.copytree('css', 'build/css', dirs_exist_ok=True)
render_leaderboard()

View file

@ -75,3 +75,10 @@ def get_rating_type(clue_starved: bool):
return 1
else:
return 0
def describe_rating_type(rating_type: int):
if rating_type == 0:
return "Standard"
elif rating_type == 1:
return "Clue Starved"

View file

@ -2,19 +2,22 @@
{% block content %}
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade active show" id="summary">
<div class="container my-5">
<!-- Leader Cards -->
<div class="card-deck mb-5">
{% for rating_type, leaders in leaders.items() %}
<div class="card-deck mb-5">
{% for category, data in leaders.items() %}
<div class="card text-center">
<div class="card-body">
<h5 class="card-title mb-4">{{ data.title }}</h5>
<h5 class="card-title mb-2">{{ data.title }}</h5>
<p class="leaderboard-category">({{data.category}})</p>
<p class="mb-0 player-name">{{ data.entry.player_name }}</p>
<p class="mt-1 alt-name">{{ data.entry.user_accounts }}</p>
<p class="score-large">{{ data.entry.score }}</p>
</div>
</div>
{% endfor %}
</div>
{% endfor %}
</div>
</div>