</tbody>
</table>
+##### TOP SCORERS #####
+<div class="table_block">
+<h2>Top Scoring Players</h2>
+<table>
+ <thead>
+ <tr>
+ <th>#</th>
+ <th>Nick</th>
+ <th>Score</th>
+ </tr>
+ </thead>
+ <tbody>
+ <% i = 1 %>
+ % for (score_player_id, score_nick, score_value) in top_scorers:
+ <tr>
+ <td>${i}</td>
+ % if score_player_id != '-':
+ <td><a href="${request.route_url('player_info', id=score_player_id)}" title="Go to the player info page for this player">${score_nick|n}</a></td>
+ % else:
+ <td>${score_nick}</td>
+ % endif
+ <td>${score_value}</td>
+ </tr>
+ <% i = i+1 %>
+ % endfor
+ </tbody>
+</table>
+</div>
+
##### TOP PLAYERS #####
<div class="table_block">
for i in range(leaderboard_count-len(top_maps)):\r
top_maps.append(('-', '-', '-'))\r
\r
+ # top players by score\r
+ top_scorers = DBSession.query(Player.player_id, Player.nick, \r
+ func.sum(PlayerGameStat.score)).\\r
+ filter(Player.player_id == PlayerGameStat.player_id).\\r
+ filter(Game.game_id == PlayerGameStat.game_id).\\r
+ filter(Game.server_id == server.server_id).\\r
+ filter(Player.player_id > 2).\\r
+ filter(PlayerGameStat.create_dt > \r
+ (datetime.now() - timedelta(days=leaderboard_lifetime))).\\r
+ order_by(expr.desc(func.sum(PlayerGameStat.score))).\\r
+ group_by(Player.nick).\\r
+ group_by(Player.player_id).all()[0:10]\r
+\r
+ top_scorers = [(player_id, html_colors(nick), score) \\r
+ for (player_id, nick, score) in top_scorers]\r
+\r
+ for i in range(leaderboard_count-len(top_scorers)):\r
+ top_scorers.append(('-', '-', '-'))\r
+\r
# top players by playing time\r
top_players = DBSession.query(Player.player_id, Player.nick, \r
func.sum(PlayerGameStat.alivetime)).\\r
return {'server':server,\r
'recent_games':recent_games,\r
'top_players': top_players,\r
+ 'top_scorers': top_scorers,\r
'top_maps': top_maps,\r
}\r
\r