Skip to content

Commit

Permalink
revert leaderboard.html
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennanB committed Aug 14, 2024
1 parent 12e756c commit ae964b7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
27 changes: 16 additions & 11 deletions ranked/templates/ranked/leaderboard.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends 'home/base.html' %}
{% block content %}
{% extends 'home/base.html' %}
{% block content %}
{% load rank_filter %}

<div class="position-relative overflow-hidden text-center bg-primary">
Expand All @@ -10,7 +10,10 @@ <h1 style="color: white" class="display-4 fw-normal">
</div>
</div>

<table class="table table-dark table-striped table-hover table-sm" style="text-align: center">
<table
class="table table-dark table-striped table-hover table-sm"
style="text-align: center"
>
<thead>
<tr>
<th>#</th>
Expand All @@ -28,19 +31,21 @@ <h1 style="color: white" class="display-4 fw-normal">
<tbody>
{% for player in players %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{forloop.counter}}</td>
<td>
<a href="/ranked/{{ leaderboard_code }}/{{ player.player.id }}">{{ player.player }}</a>
<a href="/ranked/{{leaderboard_code}}/{{player.player.id}}"
>{{player.player}}</a
>
</td>
<td>{{ player.elo|floatformat:1 }}</td>
<td>{{ player.mmr|floatformat:1 }}</td>
{% mmr_to_rank player.mmr highest_mmr lowest_mmr as rank rank_color %}
<td>{{ rank }} ({{ rank_color }})</td>
<td>{{ player.matches_played }}</td>
{% mmr_to_rank player.mmr highest_mmr lowest_mmr as rank %}
<td>{{ rank }}</td>
<td>{{player.matches_played}}</td>
<td>{{ player.win_rate|floatformat:2 }}%</td>
<td>{{ player.matches_won }}</td>
<td>{{ player.matches_lost }}</td>
<td>{{ player.matches_drawn }}</td>
<td>{{player.matches_won}}</td>
<td>{{player.matches_lost}}</td>
<td>{{player.matches_drawn}}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
4 changes: 2 additions & 2 deletions ranked/templatetags/rank_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
@register.simple_tag
def mmr_to_rank(mmr, highest_mmr, lowest_mmr):
if highest_mmr == lowest_mmr:
return 'Stone', '#ffffff' # All players have the same MMR, edge case
return 'Stone', '#ffffff'

# Calculate the percentile
percentile = (highest_mmr - mmr) / (highest_mmr - lowest_mmr)

# Determine rank based on percentile
if percentile <= 0.1:
return 'Challenger', '#ffffff'
Expand Down

0 comments on commit ae964b7

Please sign in to comment.