Commit ea426494 authored by Lukas Burgey's avatar Lukas Burgey

Change look of best player per type table

parent ae8bc6aa
......@@ -738,26 +738,33 @@ class Game(dbmodels.Model):
def best_player_per_type(it):
return get_cached(modules[__name__], '_best_player_per_type', it)
def _best_player_per_type(it):
type_list = []
for the_type in Game.type_list_ordered():
def player_list_type(t):
player_list = []
for player in Game.player_list().filter(game_type=the_type):
for player in Game.player_list().filter(game_type=t):
player_games = Game.all_games(it)\
.filter(player0=player)\
.filter(game_type=t)
win_ratio = Game.win_ratio(
Game.all_games(it)
.filter(game_type=the_type)
.filter(player0=player)
player_games
.values_list('won', flat=True)
)
player_list.append({
'player': player,
'win_ratio': win_ratio,
'game_count': len(player_games),
})
type_list.append({
'type': the_type,
'player_list': sorted(player_list, key=lambda e: -e['win_ratio']),
})
player_list = sorted(player_list, key=lambda e: (-e['win_ratio'], -e['game_count']))
return {
'type': t,
'player_list': player_list,
}
type_list = []
for t in Game.type_list_ordered():
type_list.append(player_list_type(t))
return type_list
......
......@@ -4,11 +4,16 @@ td, th {
text-align: center
}
/*
table {
border-collapse:separate;
border-radius:6px;
-moz-border-radius:6px;
}
*/
table.table.table-compressed>tbody>tr>td {
padding: 5px;
}
form table * {
text-align: left;
......@@ -41,19 +46,11 @@ th {
border-top: none;
}
thead * {
font-size: 90%;
font-weight: bold;
}
td table td {
border-top: none;
padding: 3px;
}
/*
.table-hidden>tbody>tr:first-child>td {
font-weight: bold;
}
*/
.well>.canvas {
padding: 15px;
......
......@@ -70,12 +70,13 @@
<tbody>
<tr>
{% for row in best_player_per_type %}
<td>
<table class="table">
<td style="padding: 0px 0px;">
<table class="table table-compressed">
{% for player in row.player_list %}
<tr>
<td>{{ player.win_ratio|floatformat:-2}}</td>
<td>{{ player.player }}</td>
<td>{{ player.game_count }}</td>
</tr>
{% endfor %}
</table>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment