]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Add a better to_dict() implementation for pgstats.
authorAnt Zucaro <azucaro@gmail.com>
Sat, 15 Dec 2018 18:21:39 +0000 (13:21 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Sat, 15 Dec 2018 18:21:39 +0000 (13:21 -0500)
xonstat/models/game.py

index 8d6640e39d09681778f2f72f2c3b6ff7de4774b1..efb34a6d11a589d1a85d25017ecbed457951c45f 100644 (file)
@@ -45,14 +45,40 @@ class PlayerGameStat(object):
         return "<PlayerGameStat({0.player_id}, {0.game_id}, {0.create_dt})>".format(self)
 
     def to_dict(self):
+
+        if self.fastest:
+            fastest = round(float(self.fastest.seconds) + (self.fastest.microseconds/1000000.0), 2)
+        else:
+            fastest = None
+
         return {
+            'player_game_stat_id': self.player_game_stat_id,
             'player_id': self.player_id,
             'game_id': self.game_id,
-            'create_dt': self.create_dt.strftime('%Y-%m-%dT%H:%M:%SZ'),
-            'alivetime': self.alivetime,
-            'rank': self.rank,
+            'nick': self.nick,
+            'stripped_nick': self.stripped_nick,
+            'team': self.team,
+            'alivetime': self.alivetime.total_seconds(),
+            'kills': self.kills,
+            'deaths': self.deaths,
+            'suicides': self.suicides,
             'score': self.score,
-            'team': self.team
+            'time': self.time.total_seconds() if self.time else None,
+            'captures': self.captures,
+            'pickups': self.pickups,
+            'drops': self.drops,
+            'returns': self.returns,
+            'collects': self.collects,
+            'destroys': self.destroys,
+            'pushes': self.pushes,
+            'carrier_frags': self.carrier_frags,
+            'fastest': fastest,
+            'scoreboardpos': self.scoreboardpos,
+            'laps': self.laps,
+            'revivals': self.revivals,
+            'lives': self.lives,
+            'rank': self.rank,
+            'create_dt': self.create_dt.strftime('%Y-%m-%dT%H:%M:%SZ'),
         }
 
     def nick_stripped(self):