% if recent_games:
<h2>Recent Games</h2>
<ul>
-% for (game_id, server_id, server_name, map_id, map_name) in recent_games:
- <li><a href="${request.route_url("map_info", id=map_id)}" name="Map info page for ${map_name}">${map_name}</a> (game <a href="${request.route_url("game_info", id=game_id)}" name="Game info page for game #${game_id}">#${game_id}</a>)</li>
+% for (game, theserver, map) in recent_games:
+ <li><a href="${request.route_url("map_info", id=map.map_id)}" name="Map info page for ${map.name}">${map.name}</a> (game <a href="${request.route_url("game_info", id=game.game_id)}" name="Game info page for game #${game.game_id}">#${game.game_id}</a>)</li>
% endfor
</ul>
More games played on ${server.name}...
server_id = request.matchdict['id']
try:
server = DBSession.query(Server).filter_by(server_id=server_id).one()
- recent_games = DBSession.query("game_id", "server_id", "server_name",
- "map_id", "map_name").\
- from_statement("select g.game_id, s.server_id, "
- "s.name as server_name, m.map_id, m.name as map_name "
- "from games g, servers s, maps m "
- "where g.server_id=:server_id "
- "and g.server_id = s.server_id "
- "and g.map_id = m.map_id "
- "order by g.start_dt desc "
- "limit 10 offset 1").\
- params(server_id=server_id).all()
+ recent_games = DBSession.query(Game, Server, Map).\
+ filter(Game.server_id == server_id).\
+ filter(Game.server_id == Server.server_id).\
+ filter(Game.map_id == Map.map_id).\
+ order_by(Game.game_id.desc())[0:10]
+
+ #recent_games = DBSession.query("game_id", "server_id", "server_name",
+ #"map_id", "map_name").\
+ #from_statement("select g.game_id, s.server_id, "
+ #"s.name as server_name, m.map_id, m.name as map_name "
+ #"from games g, servers s, maps m "
+ #"where g.server_id=:server_id "
+ #"and g.server_id = s.server_id "
+ #"and g.map_id = m.map_id "
+ #"order by g.start_dt desc "
+ #"limit 10 offset 1").\
+ #params(server_id=server_id).all()
except Exception as e:
server = None