Skip to content

Commit

Permalink
Factor out events and classes lists
Browse files Browse the repository at this point in the history
These lists will be reused by the clone_logs importer.

Signed-off-by: Sean Anderson <[email protected]>
  • Loading branch information
Forty-Bot committed Aug 27, 2021
1 parent e588e41 commit 25ba087
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
18 changes: 18 additions & 0 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand Down
8 changes: 4 additions & 4 deletions import.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 25ba087

Please sign in to comment.