# MAIN SUBMISSION ROUTE
config.add_route("submit_stats", "stats/submit")
- config.add_view(submit_stats, route_name="submit_stats")
+ config.add_view(submit_stats, route_name="submit_stats", renderer="submit_stats.mako")
# PLAYER ROUTES
config.add_route("player_game_index", "/player/{player_id:\d+}/games")
--- /dev/null
+V 1
+R XonStat/1.0
+T ${now}
+S ${request.route_url('server_info', id=server.server_id)}
+G ${request.route_url('game_info', id=game.game_id)}
+M ${request.route_url('map_info', id=gmap.map_id)}
+% for player_id in player_ids:
+P ${hashkeys[player_id]}
+i ${request.route_url('player_info', id=player_id)}
+% if player_id in elos:
+e elo ${elos[player_id].elo.elo}
+e elo_delta ${elos[player_id].elo_delta}
+e elo_games ${elos[player_id].elo.games}
+e k-factor ${elos[player_id].k}
+e score-per-second ${elos[player_id].score_per_second}
+e alivetime ${elos[player_id].alivetime}
+% endif
+% endfor
import re
import time
import sqlalchemy.sql.expression as expr
+from calendar import timegm
from pyramid.response import Response
from sqlalchemy import Sequence
from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound
# keep track of the players we've seen
player_ids = []
pgstats = []
+ hashkeys = {}
for events in raw_players:
player = get_or_create_player(
session = session,
pgstats.append(pgstat)
if player.player_id > 1:
- anticheats = create_anticheats(session, pgstat, game, player,
- events)
+ anticheats = create_anticheats(session, pgstat, game, player, events)
if player.player_id > 2:
player_ids.append(player.player_id)
+ hashkeys[player.player_id] = events['P']
if should_do_weapon_stats(game_type_cd) and player.player_id > 1:
pwstats = create_weapon_stats(session, game_meta, game, player,
session.commit()
log.debug('Success! Stats recorded.')
- return Response('200 OK')
+
+ # plain text response
+ request.response.content_type = 'text/plain'
+
+ return {
+ "now" : timegm(datetime.datetime.utcnow().timetuple()),
+ "server" : server,
+ "game" : game,
+ "gmap" : gmap,
+ "player_ids" : player_ids,
+ "hashkeys" : hashkeys,
+ "elos" : ep.wip,
+ }
+
except Exception as e:
if session:
session.rollback()