move leader cards to summary page
This commit is contained in:
parent
0b67cea089
commit
55148c48ab
4 changed files with 37 additions and 15 deletions
|
@ -1,11 +1,14 @@
|
||||||
.player-name {
|
.player-name {
|
||||||
font-size: 1.25rem;
|
font-size: 1.5rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
.alt-name {
|
.alt-name {
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
color: #777;
|
color: #777;
|
||||||
}
|
}
|
||||||
|
.leaderboard-category {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
}
|
||||||
.score {
|
.score {
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
import shutil
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict, List
|
from typing import Dict, List
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
|
||||||
import jinja2
|
import jinja2
|
||||||
import datetime
|
import datetime
|
||||||
import psycopg2.extras
|
import psycopg2.extras
|
||||||
|
@ -28,6 +31,7 @@ class PlayerStreakEntry(PlayerEntry):
|
||||||
@dataclass
|
@dataclass
|
||||||
class Leader:
|
class Leader:
|
||||||
title: str
|
title: str
|
||||||
|
category: str
|
||||||
entry: PlayerEntry
|
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:
|
if len(rating_list) != 0:
|
||||||
leader = rating_list[0]
|
leader = rating_list[0]
|
||||||
leaders[rating_type] = {
|
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():
|
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', leader)
|
leaders[rating_type]['Top Streak'] = Leader('Longest Win Streak', utils.describe_rating_type(rating_type), leader)
|
||||||
return leaders
|
return leaders
|
||||||
|
|
||||||
|
|
||||||
|
@ -254,7 +258,9 @@ def render_leaderboard():
|
||||||
# variants=variants,
|
# 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)
|
output_file.parent.mkdir(exist_ok=True, parents=True)
|
||||||
with open(output_file, 'w') as f:
|
with open(output_file, 'w') as f:
|
||||||
f.write(rendered_html)
|
f.write(rendered_html)
|
||||||
|
@ -269,11 +275,14 @@ def render_leaderboard():
|
||||||
variant_name=variant_names[variant_id]
|
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)
|
output_file.parent.mkdir(exist_ok=True, parents=True)
|
||||||
|
|
||||||
with open(output_file, 'w') as f:
|
with open(output_file, 'w') as f:
|
||||||
f.write(rendered_var)
|
f.write(rendered_var)
|
||||||
|
|
||||||
|
# Copy CSS to output directory
|
||||||
|
shutil.copytree('css', 'build/css', dirs_exist_ok=True)
|
||||||
|
|
||||||
|
|
||||||
render_leaderboard()
|
render_leaderboard()
|
||||||
|
|
|
@ -75,3 +75,10 @@ def get_rating_type(clue_starved: bool):
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def describe_rating_type(rating_type: int):
|
||||||
|
if rating_type == 0:
|
||||||
|
return "Standard"
|
||||||
|
elif rating_type == 1:
|
||||||
|
return "Clue Starved"
|
|
@ -2,19 +2,22 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="tab-content" id="myTabContent">
|
<div class="tab-content" id="myTabContent">
|
||||||
<div class="tab-pane fade active show" id="summary">
|
<div class="tab-pane fade active show" id="summary">
|
||||||
|
<div class="container my-5">
|
||||||
<!-- Leader Cards -->
|
<!-- Leader Cards -->
|
||||||
<div class="card-deck mb-5">
|
|
||||||
{% for rating_type, leaders in leaders.items() %}
|
{% for rating_type, leaders in leaders.items() %}
|
||||||
|
<div class="card-deck mb-5">
|
||||||
{% for category, data in leaders.items() %}
|
{% for category, data in leaders.items() %}
|
||||||
<div class="card text-center">
|
<div class="card text-center">
|
||||||
<div class="card-body">
|
<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="mb-0 player-name">{{ data.entry.player_name }}</p>
|
||||||
<p class="mt-1 alt-name">{{ data.entry.user_accounts }}</p>
|
<p class="mt-1 alt-name">{{ data.entry.user_accounts }}</p>
|
||||||
<p class="score-large">{{ data.entry.score }}</p>
|
<p class="score-large">{{ data.entry.score }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue