- for (pwstat, pgstat, weapon) in DBSession.query(PlayerWeaponStat, PlayerGameStat, Weapon).\
- filter(PlayerWeaponStat.game_id == game_id).\
- filter(PlayerWeaponStat.weapon_cd == Weapon.weapon_cd).\
- filter(PlayerWeaponStat.player_game_stat_id == \
- PlayerGameStat.player_game_stat_id).\
- order_by(PlayerGameStat.scoreboardpos).\
- order_by(PlayerGameStat.score).\
- order_by(Weapon.descr).\
- all():
- if pgstat.player_game_stat_id not in pwstats:
- pwstats[pgstat.player_game_stat_id] = []
-
- # NOTE adding pgstat to position 6 in order to display nick.
- # You have to use a slice [0:5] to pass to the accuracy
- # template
- pwstats[pgstat.player_game_stat_id].append((weapon.descr,
- weapon.weapon_cd, pwstat.actual, pwstat.max,
- pwstat.hit, pwstat.fired, pgstat))
-
- except Exception as inst:
- game = None
- server = None
- map = None
- pgstats = None
- pwstats = None
- captimes = None
- show_elo = False
- raise inst
-
- return {'game':game,
- 'server':server,
- 'map':map,
- 'pgstats':pgstats,
- 'pwstats':pwstats,
- 'captimes':captimes,
- 'show_elo':show_elo,
- }
+ for (pwstat, weapon) in DBSession.query(PlayerWeaponStat, Weapon)\
+ .filter(PlayerWeaponStat.game_id == game_id)\
+ .filter(PlayerWeaponStat.weapon_cd == Weapon.weapon_cd)\
+ .order_by(PlayerWeaponStat.actual.desc())\
+ .all():
+ if pwstat.player_game_stat_id not in pwstats:
+ pwstats[pwstat.player_game_stat_id] = []
+
+ pwstats[pwstat.player_game_stat_id].append((weapon.descr,
+ weapon.weapon_cd, pwstat.actual, pwstat.max,
+ pwstat.hit, pwstat.fired, pwstat.frags))
+
+ frag_matrix = DBSession.query(PlayerGameFragMatrix)\
+ .filter(PlayerGameFragMatrix.game_id == game_id)\
+ .all()
+
+ matrix_by_pgstat_id = {e.player_game_stat_id: e for e in frag_matrix}
+ if len(matrix_by_pgstat_id):
+ show_frag_matrix = True
+ else:
+ show_frag_matrix = False
+
+ except NoResultFound as e:
+ raise httpexceptions.HTTPNotFound("Could not find that game!")
+
+ except Exception as e:
+ raise e
+
+ return {
+ 'game': game,
+ 'server': server,
+ 'map': map,
+ 'gametype': gametype,
+ 'pgstats': pgstats,
+ 'tgstats': tgstats,
+ 'pwstats': pwstats,
+ 'captimes': captimes,
+ 'show_elo': show_elo,
+ 'show_latency': show_latency,
+ 'stats_by_team': stats_by_team,
+ 'show_frag_matrix': show_frag_matrix,
+ 'matrix_by_pgstat_id': matrix_by_pgstat_id,
+ }