From 3329d8ad1045cda719a6cfdcb2db9a7eff623a0e Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Tue, 5 Feb 2013 03:38:51 -0500 Subject: [PATCH] Save the server port number during submission --- xonstat/views/submission.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/xonstat/views/submission.py b/xonstat/views/submission.py index ca67e57..4541bdf 100644 --- a/xonstat/views/submission.py +++ b/xonstat/views/submission.py @@ -349,7 +349,7 @@ def update_fastest_cap(session, player_id, game_id, map_id, captime): session.flush() -def get_or_create_server(session, name, hashkey, ip_addr, revision): +def get_or_create_server(session, name, hashkey, ip_addr, revision, port): """ Find a server by name or create one if not found. Parameters: @@ -359,6 +359,11 @@ def get_or_create_server(session, name, hashkey, ip_addr, revision): """ server = None + try: + port = int(port) + except: + port = None + # finding by hashkey is preferred, but if not we will fall # back to using name only, which can result in dupes if hashkey is not None: @@ -400,6 +405,10 @@ def get_or_create_server(session, name, hashkey, ip_addr, revision): server.ip_addr = ip_addr session.add(server) + if server.port != port: + server.port = port + session.add(server) + if server.revision != revision: server.revision = revision session.add(server) @@ -772,7 +781,8 @@ def submit_stats(request): hashkey = idfp, name = game_meta['S'], revision = revision, - ip_addr = get_remote_addr(request)) + ip_addr = get_remote_addr(request), + port = game_meta.get('U', None)) gmap = get_or_create_map( session = session, -- 2.39.2