<tr>
<th></th>
<th>Type</th>
+ <th>Server</th>
<th>Time</th>
<th>Winner</th>
</tr>
</thead>
<tbody>
- % for (game, srv, map, pgstat) in recent_games:
- % if game != '-':
+ % for rg in recent_games:
<tr>
- <td><a class="btn btn-primary btn-small" href="${request.route_url('game_info', id=game.game_id)}" title="View detailed information about this game">View</a></td>
- <td class="gt_icon"><img title="${game.game_type_cd}" src="/static/images/icons/24x24/${game.game_type_cd}.png" alt="${game.game_type_cd}" /></td>
- <td><span class="abstime" data-epoch="${game.epoch()}" title="${game.start_dt.strftime('%a, %d %b %Y %H:%M:%S UTC')}">${game.fuzzy_date()}</span></td>
+ <td><a class="btn btn-primary btn-small" href="${request.route_url('game_info', id=rg.game_id)}" title="View detailed information about this game">View</a></td>
+ <td class="gt_icon"><img title="${rg.game_type_cd}" src="/static/images/icons/24x24/${rg.game_type_cd}.png" alt="${rg.game_type_cd}" /></td>
+ <td><a href="${request.route_url('server_info', id=rg.server_id)}" title="Go to the detail page for this server">${rg.server_name}</a></td>
+ <td><span class="abstime" data-epoch="${rg.epoch}" title="${rg.create_dt.strftime('%a, %d %b %Y %H:%M:%S UTC')}">${rg.fuzzy_date}</span></td>
<td>
- % if pgstat.player_id > 2:
- <a href="${request.route_url('player_info', id=pgstat.player_id)}" title="Go to the player info page for this player">${pgstat.nick_html_colors()|n}</a>
- </td>
+ % if rg.player_id > 2:
+ <a href="${request.route_url('player_info', id=rg.player_id)}" title="Go to the player info page for this player">${rg.nick_html_colors|n}</a>
% else:
- ${pgstat.nick_html_colors()|n}
- </td>
+ ${rg.nick_html_colors|n}
% endif
+ </td>
</tr>
- % else:
- <tr>
- <td>-</td>
- <td>-</td>
- <td>-</td>
- <td>-</td>
- </tr>
- % endif
- % endfor
- </tbody>
+ % endfor
+ </tbody>
</table>
</div>
</div>
import sqlalchemy.sql.expression as expr
from collections import namedtuple
from datetime import datetime, timedelta
-from pyramid.response import Response
from sqlalchemy import desc
from webhelpers.paginate import Page, PageURL
from xonstat.models import *
from xonstat.util import page_url, html_colors
+from xonstat.views.helpers import RecentGame, recent_games_q
log = logging.getLogger(__name__)
try:
gmap = DBSession.query(Map).filter_by(map_id=map_id).one()
- # recent games on this map
- recent_games = DBSession.query(Game, Server, Map, PlayerGameStat).\
- filter(Game.server_id==Server.server_id).\
- filter(Game.map_id==Map.map_id).\
- filter(Game.map_id==map_id).\
- filter(PlayerGameStat.game_id==Game.game_id).\
- filter(PlayerGameStat.rank==1).\
- order_by(expr.desc(Game.start_dt)).all()[0:recent_games_count]
+ # recent games played in descending order
+ rgs = recent_games_q(map_id=map_id).limit(recent_games_count).all()
+ recent_games = [RecentGame(row) for row in rgs]
# top players by score
top_scorers = DBSession.query(Player.player_id, Player.nick,