]> de.git.xonotic.org Git - xonotic/xonstat.git/blobdiff - xonstat/models.py
dos2unix file conversions for everything
[xonotic/xonstat.git] / xonstat / models.py
old mode 100755 (executable)
new mode 100644 (file)
index 50d0a35..d5cd885
@@ -1,3 +1,4 @@
+import json
 import logging
 import math
 import sqlalchemy
@@ -66,6 +67,9 @@ class Map(object):
     def __repr__(self):
         return "<Map(%s, %s, %s)>" % (self.map_id, self.name, self.version)
 
+    def to_dict(self):
+        return {'map_id':self.map_id, 'name':self.name}
+
 
 class Game(object):
     def __init__(self, game_id=None, start_dt=None, game_type_cd=None, 
@@ -270,6 +274,20 @@ class PlayerElo(object):
                 (self.player_id, self.game_type_cd, self.elo)
 
 
+class PlayerRank(object):
+
+    def nick_html_colors(self):
+        if self.nick is None:
+            return "Anonymous Player"
+        else:
+            return html_colors(self.nick)
+
+
+    def __repr__(self):
+        return "<PlayerRank(pid=%s, gametype=%s, rank=%s)>" % \
+                (self.player_id, self.game_type_cd, self.rank)
+
+
 def initialize_db(engine=None):
     DBSession.configure(bind=engine)
     Base.metadata.bind = engine
@@ -291,6 +309,7 @@ def initialize_db(engine=None):
     servers_table = MetaData.tables['servers']
     player_nicks_table = MetaData.tables['player_nicks']
     player_elos_table = MetaData.tables['player_elos']
+    player_ranks_table = MetaData.tables['player_ranks']
 
     # now map the tables and the objects together
     mapper(PlayerAchievement, achievements_table)
@@ -306,3 +325,4 @@ def initialize_db(engine=None):
     mapper(Server, servers_table)
     mapper(PlayerNick, player_nicks_table)
     mapper(PlayerElo, player_elos_table)
+    mapper(PlayerRank, player_ranks_table)