Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
formula student elo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GET racing FOSS
formula student elo
Commits
8852492a
Commit
8852492a
authored
3 months ago
by
maeries
Browse files
Options
Downloads
Patches
Plain Diff
added world ranking info to team page
parent
7e8ebf15
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
main.py
+42
-27
42 additions, 27 deletions
main.py
team_page.py
+14
-6
14 additions, 6 deletions
team_page.py
with
56 additions
and
33 deletions
main.py
+
42
−
27
View file @
8852492a
...
...
@@ -155,6 +155,9 @@ class EloSystem:
# For each team, compare with teams ranked below them
date
=
self
.
get_competition_date
(
competition_id
)
# Use current date as competition date
old_world_ranking
=
sorted
(
self
.
teams
.
items
(),
key
=
lambda
x
:
x
[
1
][
'
elo
'
],
reverse
=
True
)
old_world_ranking
=
tuple
(
name
for
name
,
_
in
old_world_ranking
)
for
i
in
range
(
len
(
teams_in_order
)):
for
j
in
range
(
i
+
1
,
len
(
teams_in_order
)):
team_a
=
teams_in_order
[
i
]
...
...
@@ -165,29 +168,41 @@ class EloSystem:
# Store post-competition Elo ratings and changes
for
team
in
teams_in_order
:
rank
=
teams_in_order
.
index
(
team
)
+
1
placement
=
teams_in_order
.
index
(
team
)
+
1
previous_elo
=
self
.
teams
[
team
][
'
elo
'
]
elo_change
=
self
.
teams
[
team
][
'
delta_elo
'
]
old_rank
=
old_world_ranking
.
index
(
team
)
+
1
new_rank
=
0
# Store in team history
self
.
teams
[
team
][
'
history
'
].
append
({
'
date
'
:
date
.
strftime
(
"
%Y-%m-%d
"
),
'
competition
'
:
self
.
get_competition_name
(
competition_id
),
'
competition_id
'
:
competition_id
,
'
rank
'
:
rank
,
'
placement
'
:
placement
,
'
participants
'
:
len
(
teams_in_order
),
'
previous_elo
'
:
previous_elo
,
'
new_elo
'
:
self
.
teams
[
team
][
'
elo
'
]
+
self
.
teams
[
team
][
'
delta_elo
'
],
'
elo_change
'
:
elo_change
'
elo_change
'
:
elo_change
,
'
old_rank
'
:
old_rank
,
'
new_rank
'
:
new_rank
,
'
rank_change
'
:
new_rank
-
old_rank
})
# Store in competition history
self
.
competition_history
[
competition_id
][
'
results
'
][
rank
-
1
][
2
]
=
previous_elo
self
.
competition_history
[
competition_id
][
'
results
'
][
rank
-
1
][
3
]
=
elo_change
self
.
competition_history
[
competition_id
][
'
results
'
][
placement
-
1
][
2
]
=
previous_elo
self
.
competition_history
[
competition_id
][
'
results
'
][
placement
-
1
][
3
]
=
elo_change
self
.
teams
[
team
][
'
elo
'
]
=
self
.
teams
[
team
][
'
elo
'
]
+
self
.
teams
[
team
][
'
delta_elo
'
]
self
.
teams
[
team
][
'
delta_elo
'
]
=
0
for
team
in
teams_in_order
:
new_world_ranking
=
sorted
(
self
.
teams
.
items
(),
key
=
lambda
x
:
x
[
1
][
'
elo
'
],
reverse
=
True
)
new_world_ranking
=
tuple
(
name
for
name
,
_
in
new_world_ranking
)
new_rank
=
new_world_ranking
.
index
(
team
)
+
1
self
.
teams
[
team
][
'
history
'
][
-
1
][
'
new_rank
'
]
=
new_rank
self
.
teams
[
team
][
'
history
'
][
-
1
][
'
rank_change
'
]
=
new_rank
-
self
.
teams
[
team
][
'
history
'
][
-
1
][
'
old_rank
'
]
def
update_elo_pair
(
self
,
team_a
,
team_b
,
score_a
,
score_b
,
competition_id
,
date
):
"""
Update Elo ratings for a pair of teams based on their match outcome
"""
# Get current Elo ratings
...
...
@@ -448,7 +463,7 @@ class EloSystem:
# Add competition labels
for
i
,
entry
in
enumerate
(
team_history
):
plt
.
annotate
(
entry
[
'
competition
'
]
+
f
"
(#
{
entry
[
'
rank
'
]
}
)
"
,
plt
.
annotate
(
entry
[
'
competition
'
]
+
f
"
(#
{
entry
[
'
placement
'
]
}
)
"
,
(
i
,
entry
[
'
new_elo
'
]),
textcoords
=
"
offset points
"
,
xytext
=
(
0
,
10
),
...
...
This diff is collapsed.
Click to expand it.
team_page.py
+
14
−
6
View file @
8852492a
...
...
@@ -149,8 +149,8 @@ def get_team_page_html(self, team_name, team_data, team_competitions):
# Calculate average ranking if available
if
team_competitions
:
avg_rank
=
sum
(
comp
[
'
rank
'
]
for
comp
in
team_competitions
)
/
len
(
team_competitions
)
best_rank
=
min
(
comp
[
'
rank
'
]
for
comp
in
team_competitions
)
avg_rank
=
sum
(
comp
[
'
placement
'
]
for
comp
in
team_competitions
)
/
len
(
team_competitions
)
best_rank
=
min
(
comp
[
'
placement
'
]
for
comp
in
team_competitions
)
html_content
+=
f
"""
<div class=
"
stat-box
"
>
...
...
@@ -175,8 +175,11 @@ def get_team_page_html(self, team_name, team_data, team_competitions):
<table>
<tr>
<th>Date</th>
<th>Comp
etition
</th>
<th>Comp</th>
<th>Placement</th>
<th>Rank Before</th>
<th>Rank After</th>
<th>Rank Change</th>
<th>Elo Before</th>
<th>Elo After</th>
<th>Elo Change</th>
...
...
@@ -186,16 +189,21 @@ def get_team_page_html(self, team_name, team_data, team_competitions):
# Add rows for each competition
for
comp
in
team_competitions
:
elo_change
=
comp
[
'
elo_change
'
]
change_class
=
"
positive
"
if
elo_change
>
0
else
"
negative
"
if
elo_change
<
0
else
""
elo_change_class
=
"
positive
"
if
elo_change
>
0
else
"
negative
"
if
elo_change
<
0
else
""
rank_change
=
comp
[
'
rank_change
'
]
rank_change_class
=
"
positive
"
if
rank_change
<
0
else
"
negative
"
if
rank_change
>
0
else
""
html_content
+=
f
"""
<tr>
<td>
{
comp
[
'
date
'
]
}
</td>
<td><a href=../comp/
{
comp
[
'
competition_id
'
]
}
.html>
{
comp
[
'
competition
'
]
}
</a></td>
<td>
{
comp
[
'
rank
'
]
}
/
{
comp
[
'
participants
'
]
}
</td>
<td>
{
comp
[
'
placement
'
]
}
/
{
comp
[
'
participants
'
]
}
</td>
<td>
{
comp
[
'
old_rank
'
]
}
</td>
<td>
{
comp
[
'
new_rank
'
]
}
</td>
<td class=
"
{
rank_change_class
}
"
>
{
'
+
'
if
rank_change
>
0
else
''
}{
comp
[
'
rank_change
'
]
}
</td>
<td>
{
int
(
comp
[
'
previous_elo
'
])
}
</td>
<td>
{
int
(
comp
[
'
new_elo
'
])
}
</td>
<td class=
"
{
change_class
}
"
>
{
'
+
'
if
elo_change
>
0
else
''
}{
elo_change
:
.
1
f
}
</td>
<td class=
"
{
elo_
change_class
}
"
>
{
'
+
'
if
elo_change
>
0
else
''
}{
elo_change
:
.
1
f
}
</td>
</tr>
"""
html_content
+=
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment