From af93e105cd063fc6e30a6f55fb2fa70668af7db9 Mon Sep 17 00:00:00 2001 From: j Date: Mon, 22 Jan 2018 23:47:22 +0100 Subject: [PATCH] fallback if user has no events --- recommendation_engine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recommendation_engine.py b/recommendation_engine.py index 7482277..30cbbb7 100644 --- a/recommendation_engine.py +++ b/recommendation_engine.py @@ -49,7 +49,7 @@ class Engine: playlists = playlists[channels['keywords']:] # Count tags for the user count = {} - for event in user['events']: + for event in user.get('events', []): if 'product' in event['data']: count[event['data']['product']] = count.get( event['data']['product'], 0