2 Models related to maps.
5 from calendar import timegm
7 from xonstat.models.mixins import FuzzyDateMixin, EpochMixin
8 from xonstat.util import pretty_date, strip_colors, html_colors
11 class Map(FuzzyDateMixin, EpochMixin):
13 A playable map. Roughly equivalent to a pk3 file, but distinguished by name instead.
16 def __init__(self, name=None):
20 return "<Map({0.map_id}, {0.name}, {0.version})>".format(self)
24 'map_id': self.map_id,
26 'version': self.version,
30 # TODO: investigate if this model is truly a model, or really just a query (i.e. namedtuple)
31 class MapCapTime(object):
33 Fastest flag capture times per map.
36 def __init__(self, row):
37 self.fastest_cap = row.fastest_cap
38 self.create_dt = row.create_dt
39 self.create_dt_epoch = timegm(row.create_dt.timetuple())
40 self.create_dt_fuzzy = pretty_date(row.create_dt)
41 self.player_id = row.player_id
42 self.player_nick = row.player_nick
43 self.player_nick_stripped = strip_colors(row.player_nick)
44 self.player_nick_html = html_colors(row.player_nick)
45 self.game_id = row.game_id
46 self.server_id = row.server_id
47 self.server_name = row.server_name
51 "fastest_cap": self.fastest_cap.total_seconds(),
52 "create_dt_epoch": self.create_dt_epoch,
53 "create_dt_fuzzy": self.create_dt_fuzzy,
54 "player_id": self.player_id,
55 "player_nick": self.player_nick,
56 "player_nick_stripped": self.player_nick_stripped,
57 "game_id": self.game_id,
58 "server_id": self.server_id,
59 "server_name": self.server_name,