</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><a href="${request.route_url('map_info', id=map.map_id)}" title="Go to the map detail page for this map">${map.name}</a></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('map_info', id=rg.map_id)}" title="Go to the map detail page for this map">${rg.map_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>
- % else:
- ${pgstat.nick_html_colors()|n}
- </td>
- % endif
- </tr>
+ % 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:
- <tr>
- <td>-</td>
- <td>-</td>
- <td>-</td>
- <td>-</td>
- <td>-</td>
- </tr>
+ ${rg.nick_html_colors|n}
% endif
+ </td>
+ </tr>
% endfor
- </tbody>
+ </tbody>
</table>
</div>
</div>
import sqlalchemy.sql.expression as expr
import time
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__)
for (player_id, nick, score) in top_players]
# recent games played in descending order
- recent_games = DBSession.query(Game, Server, Map, PlayerGameStat).\
- filter(Game.server_id==Server.server_id).\
- filter(Game.map_id==Map.map_id).\
- filter(PlayerGameStat.game_id==Game.game_id).\
- filter(PlayerGameStat.rank==1).\
- filter(Server.server_id==server.server_id).\
- order_by(expr.desc(Game.start_dt)).all()[0:recent_games_count]
+ rgs = recent_games_q(server_id=server_id).limit(recent_games_count).all()
+ recent_games = [RecentGame(row) for row in rgs]
except Exception as e:
server = None