only count events with product

This commit is contained in:
j 2018-02-04 16:05:55 +01:00
parent 935ea07559
commit 49e045daf4

View file

@ -65,7 +65,8 @@ class Engine:
# Count tags for the user
count = defaultdict(lambda: 0)
for event in user.get('events', []):
count[event['data']['product']] += 1
if event.get('data', {}).get('product'):
count[event['data']['product']] += 1
# For each tag in playlist, increment score by count
for playlist in playlists:
score[playlist['name']] = random.random()