2 Models related to maps.
5 from calendar import timegm
7 from xonstat.util import pretty_date, strip_colors, html_colors
12 A playable map. Roughly equivalent to a pk3 file, but distinguished by name instead.
15 def __init__(self, name=None):
19 return "<Map({}, {}, {})>".format(self.map_id, self.name, self.version)
23 'map_id': self.map_id,
25 'version': self.version,
29 return pretty_date(self.create_dt)
32 return timegm(self.create_dt.timetuple())
35 # TODO: investigate if this model is truly a model, or really just a query (i.e. namedtuple)
36 class MapCapTime(object):
38 Fastest flag capture times per map.
41 def __init__(self, row):
42 self.fastest_cap = row.fastest_cap
43 self.create_dt = row.create_dt
44 self.create_dt_epoch = timegm(row.create_dt.timetuple())
45 self.create_dt_fuzzy = pretty_date(row.create_dt)
46 self.player_id = row.player_id
47 self.player_nick = row.player_nick
48 self.player_nick_stripped = strip_colors(row.player_nick)
49 self.player_nick_html = html_colors(row.player_nick)
50 self.game_id = row.game_id
51 self.server_id = row.server_id
52 self.server_name = row.server_name
56 "fastest_cap": self.fastest_cap.total_seconds(),
57 "create_dt_epoch": self.create_dt_epoch,
58 "create_dt_fuzzy": self.create_dt_fuzzy,
59 "player_id": self.player_id,
60 "player_nick": self.player_nick,
61 "player_nick_stripped": self.player_nick_stripped,
62 "game_id": self.game_id,
63 "server_id": self.server_id,
64 "server_name": self.server_name,