From 3841a67a79ac035defcd4b6b89d92cd42671fc78 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 25 Jan 2018 13:49:12 +0100 Subject: [PATCH] use events not activities --- recommendation_engine.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/recommendation_engine.py b/recommendation_engine.py index d227bfd..662edd6 100644 --- a/recommendation_engine.py +++ b/recommendation_engine.py @@ -50,12 +50,8 @@ class Engine: playlists = playlists[channels['keywords']:] # Count tags for the user count = defaultdict(lambda: 0) - for activity in user.get('activities', []): - if activity.get('type') == 'SCREENING_CHECK_IN': - product = activity.get('extras', {}).get('event', {}).get('alias') - if product: - product = product.replace('_', ' ') - count[product] += 1 + for event in user.get('events', []): + count[event['data']['product']] += 1 # For each tag in playlist, increment score by count for playlist in playlists: score[playlist['name']] = random.random()