You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.6 KiB
Python

import peewee
DATABASE = peewee.Proxy()
HYPERTABLES = ["CoDStandardStats", "CoDHcDominationStats"]
class BaseModel(peewee.Model):
class Meta:
database = DATABASE
class CoDUser(BaseModel):
user = peewee.TextField()
class CoDStandardStats(BaseModel):
ts = peewee.DateTimeField()
user = peewee.TextField()
kills = peewee.IntegerField()
deaths = peewee.IntegerField()
assists = peewee.IntegerField()
suicides = peewee.IntegerField()
total_games_played = peewee.IntegerField()
wins = peewee.IntegerField()
losses = peewee.IntegerField()
ties = peewee.IntegerField()
time_played_total = peewee.IntegerField()
average_life = peewee.FloatField()
career_score = peewee.IntegerField()
headshots = peewee.IntegerField()
total_shots = peewee.IntegerField()
hits = peewee.IntegerField()
misses = peewee.IntegerField()
class Meta:
primary_key = peewee.CompositeKey("ts", "user")
class CoDHcDominationStats(BaseModel):
ts = peewee.DateTimeField()
user = peewee.TextField()
kills = peewee.IntegerField()
deaths = peewee.IntegerField()
score = peewee.IntegerField()
time_played = peewee.IntegerField()
captures = peewee.IntegerField()
defends = peewee.IntegerField()
class Meta:
primary_key = peewee.CompositeKey("ts", "user")
def create_tables():
DATABASE.create_tables([CoDUser, CoDStandardStats, CoDHcDominationStats])
def create_hypertables():
for hypertable in HYPERTABLES:
DATABASE.execute_sql(f"SELECT create_hypertable('{hypertable}', 'ts');")