Skip to content
Snippets Groups Projects
Commit 0ae81a83 authored by Marius Heidenreich's avatar Marius Heidenreich
Browse files

removed legacy teams from ranking and added a toggle to show them again

parent 49232d60
Branches
No related tags found
No related merge requests found
Pipeline #281212 passed
......@@ -25,6 +25,17 @@ def get_competition_page_html(self, competition_id):
color: #333;
animation: fadeInUp 0.5s ease-out forwards;
}}
h2 {{
margin-top: 40px;
margin-bottom: 20px;
}}
h3 {{
color: #555;
font-weight: normal;
font-size: 16px;
margin: 0;
animation: fadeInUp 0.5s ease-out forwards;
}}
table {{
border-collapse: collapse;
width: 100%;
......@@ -212,13 +223,13 @@ def get_competition_page_html(self, competition_id):
<div style="margin-bottom: 12px; margin-top: 16px; text-align: center">sponsored by:</div>
<div class="sponsoring-flex">
<div class="sponsor">
<a href="https://murtfeldt.de" target="_blank"><img src="../murtfeldt.png" alt="Logo of Murtfeldt Kunststoffe"></a>
<a href="https://murtfeldt.de" target="_blank"><img src="../../murtfeldt.png" alt="Logo of Murtfeldt Kunststoffe"></a>
</div>
<div class="sponsor">
<a href="https://www.kordel.de" target="_blank"><img src="../kordel.png" alt="Logo of Kordel"></a>
<a href="https://www.kordel.de" target="_blank"><img src="../../kordel.png" alt="Logo of Kordel"></a>
</div>
<div class="sponsor">
<a href="https://www.vulcanus-stahl.de/" target="_blank"><img src="../vulcanus.png" alt="Logo of Vulcanus Stahl"></a>
<a href="https://www.vulcanus-stahl.de/" target="_blank"><img src="../../vulcanus.png" alt="Logo of Vulcanus Stahl"></a>
</div>
</div>
</div>
......
......@@ -2,7 +2,7 @@ import csv
import math
import multiprocessing as mp
import os
from datetime import datetime
from datetime import datetime, timedelta
import matplotlib.patches as patches
import matplotlib.pyplot as plt
......@@ -242,14 +242,12 @@ class EloSystem:
"""Generate static HTML website with Elo ratings and visualizations"""
# If num_processes not specified, use number of CPU cores
num_processes = int(mp.cpu_count())
num_processes = int(mp.cpu_count() / 2)
print(f"staring computation on {num_processes} cores")
pool = mp.Pool(processes=num_processes)
self.create_world_ranking()
#for competition in self.competition_history:
# self.create_competition_page(competition)
self.create_world_ranking(True)
self.create_world_ranking(False)
pool.map(self.create_competition_page, self.competition_history)
......@@ -261,14 +259,22 @@ class EloSystem:
print(f"Website generated in {self.output_directory}")
def create_world_ranking(self):
def create_world_ranking(self, include_legacy):
"""Create the index.html page for the vehicle type"""
# Sort teams by Elo rating
sorted_teams = sorted(self.teams.items(), key=lambda x: x[1]['elo'], reverse=True)
html_content = get_world_ranking_html(self, sorted_teams)
if not include_legacy:
sorted_teams_active = []
for index, team in enumerate(sorted_teams):
date_last_comp = datetime.strptime(team[1]['history'][-1]['date'], "%Y-%m-%d")
if date_last_comp > datetime.now() - timedelta(days=3*365):
sorted_teams_active.append(team)
sorted_teams = sorted_teams_active
html_content = get_world_ranking_html(self, sorted_teams, include_legacy)
# Write the HTML file
with open(os.path.join(self.output_directory, 'index.html'), 'w', encoding='utf-8') as f:
filename = 'index.html' if not include_legacy else 'legacy.html'
with open(os.path.join(self.output_directory, filename), 'w', encoding='utf-8') as f:
f.write(html_content)
def create_team_page(self, team_name):
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="74.407852mm"
height="41.717289mm"
viewBox="0 0 74.407852 41.717289"
version="1.1"
id="svg1"
xml:space="preserve"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><defs
id="defs1"><linearGradient
id="linearGradient11"><stop
style="stop-color:#ff8c00;stop-opacity:1;"
offset="0"
id="stop11" /><stop
style="stop-color:#ff4500;stop-opacity:1;"
offset="1"
id="stop12" /></linearGradient><linearGradient
xlink:href="#linearGradient11"
id="linearGradient12"
x1="235.32404"
y1="248.5153"
x2="182.70973"
y2="301.12961"
gradientUnits="userSpaceOnUse" /></defs><g
id="layer1"
transform="translate(-171.81296,-253.96382)"><path
id="path7"
style="fill:url(#linearGradient12);stroke:none;stroke-width:0.853556"
d="m 193.53566,253.96382 v 0.002 a 21.749203,20.858521 0 0 0 -21.7227,20.85616 21.749203,20.858521 0 0 0 21.7227,20.85713 v 0.002 h 30.89889 v -0.003 a 21.749203,20.858521 0 0 0 0.0372,0.003 21.749203,20.858521 0 0 0 21.74906,-20.85868 21.749203,20.858521 0 0 0 -21.74906,-20.85816 21.749203,20.858521 0 0 0 -0.0372,0.003 v -0.003 z" /><ellipse
style="fill:#ffffff;stroke:none;stroke-width:0.651177"
id="ellipse8"
cx="224.4718"
cy="274.82217"
rx="16.592436"
ry="15.912936" /></g></svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="74.407852mm"
height="41.717289mm"
viewBox="0 0 74.407852 41.717289"
version="1.1"
id="svg1"
xml:space="preserve"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><defs
id="defs1"><linearGradient
id="linearGradient9"><stop
style="stop-color:#ffc400;stop-opacity:1;"
offset="0"
id="stop9" /><stop
style="stop-color:#ffff1e;stop-opacity:1;"
offset="1"
id="stop10" /></linearGradient><linearGradient
xlink:href="#linearGradient9"
id="linearGradient10"
x1="235.32405"
y1="242.92863"
x2="182.7097"
y2="190.31429"
gradientUnits="userSpaceOnUse" /></defs><g
id="layer1"
transform="translate(-171.81296,-195.76281)"><path
id="path5"
style="fill:url(#linearGradient10);stroke:none;stroke-width:0.854;stroke-dasharray:none"
d="m 193.53566,195.76281 v 0.002 a 21.749203,20.858521 0 0 0 -21.7227,20.85616 21.749203,20.858521 0 0 0 21.7227,20.85713 v 0.002 h 30.89889 v -0.003 a 21.749203,20.858521 0 0 0 0.0372,0.003 21.749203,20.858521 0 0 0 21.74906,-20.85868 21.749203,20.858521 0 0 0 -21.74906,-20.85816 21.749203,20.858521 0 0 0 -0.0372,0.003 v -0.003 z" /><ellipse
style="fill:#ffffff;stroke:none;stroke-width:0.651177"
id="ellipse6"
cx="224.4718"
cy="216.62117"
rx="16.592436"
ry="15.912936" /></g></svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="74.407852mm"
height="41.717289mm"
viewBox="0 0 74.407852 41.717289"
version="1.1"
id="svg1"
xml:space="preserve"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><defs
id="defs1" /><g
id="layer1"
transform="translate(-62.654839,-195.76281)"><path
id="path4"
style="fill:#777777;fill-opacity:1;stroke:none;stroke-width:0.853556"
d="m 84.377545,195.76281 v 0.002 A 21.749203,20.858521 0 0 0 62.65484,216.62097 21.749203,20.858521 0 0 0 84.377545,237.4781 v 0.002 h 30.898885 v -0.003 a 21.749203,20.858521 0 0 0 0.0372,0.003 21.749203,20.858521 0 0 0 21.74906,-20.85868 21.749203,20.858521 0 0 0 -21.74906,-20.85816 21.749203,20.858521 0 0 0 -0.0372,0.003 v -0.003 z" /><ellipse
style="fill:#ffffff;stroke:none;stroke-width:0.651177"
id="ellipse5"
cx="84.403786"
cy="216.62117"
rx="16.592436"
ry="15.912936" /></g></svg>
......@@ -172,6 +172,7 @@ def get_team_page_html(self, team_name, team_data, team_competitions):
</div>
<h2>Competition History</h2>
<p>Rank includes legacy teams</p>
<div style="overflow-x: scroll;">
<table>
<tr>
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="74.407852mm"
height="41.717289mm"
viewBox="0 0 74.407852 41.717289"
version="1.1"
id="svg1"
xml:space="preserve"
inkscape:version="1.4 (86a8ad7, 2024-10-11)"
sodipodi:docname="toggle_buttons.svg"
inkscape:export-filename="inactive.svg"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
inkscape:zoom="1.0592242"
inkscape:cx="-270.48098"
inkscape:cy="-100.54529"
inkscape:window-width="2560"
inkscape:window-height="1369"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
inkscape:export-bgcolor="#ffffff00"><inkscape:page
x="0"
y="0"
width="74.407852"
height="41.717289"
id="page12"
margin="0"
bleed="0" /><inkscape:page
x="-109.15812"
y="-58.201008"
width="74.407852"
height="41.717289"
id="page13"
margin="0"
bleed="0"
inkscape:export-filename="Seite 3.svg"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96" /><inkscape:page
x="0"
y="-58.201008"
width="74.407852"
height="41.717289"
id="page14"
margin="0"
bleed="0"
inkscape:export-filename="public\active_electric.svg"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96" /></sodipodi:namedview><defs
id="defs1"><linearGradient
id="linearGradient11"
inkscape:collect="always"><stop
style="stop-color:#ff8c00;stop-opacity:1;"
offset="0"
id="stop11" /><stop
style="stop-color:#ff4500;stop-opacity:1;"
offset="1"
id="stop12" /></linearGradient><linearGradient
id="linearGradient9"
inkscape:collect="always"><stop
style="stop-color:#ffc400;stop-opacity:1;"
offset="0"
id="stop9" /><stop
style="stop-color:#ffff1e;stop-opacity:1;"
offset="1"
id="stop10" /></linearGradient><linearGradient
inkscape:collect="always"
xlink:href="#linearGradient9"
id="linearGradient10"
x1="235.32405"
y1="242.92863"
x2="182.7097"
y2="190.31429"
gradientUnits="userSpaceOnUse" /><linearGradient
inkscape:collect="always"
xlink:href="#linearGradient11"
id="linearGradient12"
x1="235.32404"
y1="248.5153"
x2="182.70973"
y2="301.12961"
gradientUnits="userSpaceOnUse" /></defs><g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-171.81296,-253.96382)"><path
id="ellipse3"
style="fill:#00ff00;stroke:none;stroke-width:0.853556"
d="m 86.320453,121.22579 v 0.002 a 21.749203,20.858521 0 0 0 -21.722705,20.85661 21.749203,20.858521 0 0 0 21.722705,20.85713 v 0.002 h 30.898887 v -0.003 a 21.749203,20.858521 0 0 0 0.0372,0.003 21.749203,20.858521 0 0 0 21.74906,-20.85868 21.749203,20.858521 0 0 0 -21.74906,-20.85816 21.749203,20.858521 0 0 0 -0.0372,0.003 v -0.003 z" /><ellipse
style="fill:#ff0000;stroke:none;stroke-width:0.651177"
id="ellipse1"
cx="117.2566"
cy="142.08415"
rx="16.592436"
ry="15.912936" /><ellipse
style="fill:#ff0000;stroke:none;stroke-width:0.651177"
id="ellipse2"
cx="86.346695"
cy="142.08415"
rx="16.592436"
ry="15.912936" /><path
id="path4"
style="fill:#777777;fill-opacity:1;stroke:none;stroke-width:0.853556"
d="m 84.377545,195.76281 v 0.002 A 21.749203,20.858521 0 0 0 62.65484,216.62097 21.749203,20.858521 0 0 0 84.377545,237.4781 v 0.002 h 30.898885 v -0.003 a 21.749203,20.858521 0 0 0 0.0372,0.003 21.749203,20.858521 0 0 0 21.74906,-20.85868 21.749203,20.858521 0 0 0 -21.74906,-20.85816 21.749203,20.858521 0 0 0 -0.0372,0.003 v -0.003 z" /><ellipse
style="fill:#ffffff;stroke:none;stroke-width:0.651177"
id="ellipse5"
cx="84.403786"
cy="216.62117"
rx="16.592436"
ry="15.912936" /><path
id="path5"
style="fill:url(#linearGradient10);stroke:none;stroke-width:0.854;stroke-dasharray:none"
d="m 193.53566,195.76281 v 0.002 a 21.749203,20.858521 0 0 0 -21.7227,20.85616 21.749203,20.858521 0 0 0 21.7227,20.85713 v 0.002 h 30.89889 v -0.003 a 21.749203,20.858521 0 0 0 0.0372,0.003 21.749203,20.858521 0 0 0 21.74906,-20.85868 21.749203,20.858521 0 0 0 -21.74906,-20.85816 21.749203,20.858521 0 0 0 -0.0372,0.003 v -0.003 z" /><ellipse
style="fill:#ffffff;stroke:none;stroke-width:0.651177"
id="ellipse6"
cx="224.4718"
cy="216.62117"
rx="16.592436"
ry="15.912936" /><path
id="path7"
style="fill:url(#linearGradient12);stroke:none;stroke-width:0.853556"
d="m 193.53566,253.96382 v 0.002 a 21.749203,20.858521 0 0 0 -21.7227,20.85616 21.749203,20.858521 0 0 0 21.7227,20.85713 v 0.002 h 30.89889 v -0.003 a 21.749203,20.858521 0 0 0 0.0372,0.003 21.749203,20.858521 0 0 0 21.74906,-20.85868 21.749203,20.858521 0 0 0 -21.74906,-20.85816 21.749203,20.858521 0 0 0 -0.0372,0.003 v -0.003 z" /><ellipse
style="fill:#ffffff;stroke:none;stroke-width:0.651177"
id="ellipse8"
cx="224.4718"
cy="274.82217"
rx="16.592436"
ry="15.912936" /></g></svg>
from datetime import datetime
from tools import clean_filename
def get_world_ranking_html(self, sorted_teams):
def get_world_ranking_html(self, sorted_teams, is_legacy):
html_content = f"""<!DOCTYPE html>
<html lang="en">
<head>
......@@ -239,6 +239,49 @@ def get_world_ranking_html(self, sorted_teams):
left: 100%;
}}
.team-header {{
display: flex;
justify-content: space-between;
align-items: center;
}}
.align-horizontally {{
display: inline-grid;
grid-template-columns: auto auto;
place-items: center;
gap: 10px
}}
.tooltip {{
position: relative;
display: inline-block;
cursor: pointer;
}}
.tooltip .tooltiptext {{
visibility: hidden;
width: 200px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 5px;
padding: 5px;
position: absolute;
z-index: 1;
top: 125%; /* Position the tooltip above the text */
left: 20%;
margin-left: -60px;
opacity: 0;
transition: opacity 0.3s;
}}
.tooltip:hover .tooltiptext {{
visibility: visible;
opacity: 1;
text-transform: none;
font-weight: normal;
}}
@keyframes fadeInUp {{
from {{
opacity: 0;
......@@ -257,7 +300,7 @@ def get_world_ranking_html(self, sorted_teams):
<p>Rankings based on {len(self.competition_history)} competitions.</p>
<div class="sponsoring-container">
<div style="margin-bottom: 12px; margin-top: 16px; text-align: center">sponsored by:</div>
<div style="margin-bottom: 12px; margin-top: 16px; text-align: center; color: #555">sponsored by:</div>
<div class="sponsoring-flex">
<div class="sponsor">
<a href="https://murtfeldt.de" target="_blank"><img src="../murtfeldt.png" alt="Logo of Murtfeldt Kunststoffe"></a>
......@@ -276,7 +319,17 @@ def get_world_ranking_html(self, sorted_teams):
<table>
<tr>
<th></th>
<th>Team</th>
<th><div class="team-header">
<div>Team</div>
<div class="tooltip">
<a href={"index.html" if is_legacy else "legacy.html"} style="cursor: pointer;">
<div class="align-horizontally" style="text-transform: none; font-weight: normal;">
hide legacy teams <img src="../{"inactive" if is_legacy else "active_" + self.competition_type}.svg" height="20px" alt="toggle switch">
</div>
</a>
<span class="tooltiptext">legacy teams are those who haven't competed in 3 years</span>
</div>
</div></th>
<th>Elo Rating</th>
<th>Competitions</th>
</tr>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment