diff --git a/common.py b/common.py index 5ec5c52..303a7e0 100644 --- a/common.py +++ b/common.py @@ -4,6 +4,24 @@ from datetime import datetime, timedelta from dateutil import tz +classes = ( + 'demoman', + 'engineer', + 'heavyweapons', + 'medic', + 'pyro', + 'scout', + 'sniper', + 'soldier', + 'spy' +) + +events = { + 'classkills': 'kill', + 'classdeaths': 'death', + 'classkillassists': 'assist', +} + def get_filters(args): ret = {} diff --git a/import.py b/import.py index 3ddb402..73f6c92 100755 --- a/import.py +++ b/import.py @@ -10,6 +10,8 @@ import psycopg2 import zstandard +import common +from common import classes from fetch import ListFetcher, BulkFetcher, FileFetcher, ReverseFetcher from steamid import SteamID from sql import db_connect, db_init, table_columns @@ -198,8 +200,7 @@ def import_log(cctx, c, logid, log): %(ic)s );""", player) - for (prop, event) in (('classkills', 'kill'), ('classdeaths', 'death'), - ('classkillassists', 'assist')): + for prop, event in common.events.items(): if not log.get(prop): continue @@ -211,8 +212,7 @@ def import_log(cctx, c, logid, log): events['logid'] = logid events['steamid'] = steamid events['event'] = event - for cls in ('demoman', 'engineer', 'heavyweapons', 'medic', 'pyro', 'scout', 'sniper', - 'soldier', 'spy'): + for cls in classes: events[cls] = events.get(cls, 0) # There are also 'unknown' events, but we skip them; they can be determined by the