From 71a9effbba1b917644e88786263ddd78c870e29e Mon Sep 17 00:00:00 2001 From: pythagoraswitch Date: Wed, 25 Jul 2018 16:13:43 +0200 Subject: [PATCH] play_index extraction to incorporate the future data scheme change --- recommendation_engine.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/recommendation_engine.py b/recommendation_engine.py index 88a241b..03c6919 100644 --- a/recommendation_engine.py +++ b/recommendation_engine.py @@ -101,6 +101,17 @@ class Engine: grid_events[event.get('data').get('index')] = event.get('data') if len(grid_events) == video_num: break + + # # The version where the loop also extract play_index (requires "index" in play event data): + # play_index = None + # for event in user.get('events', []): + # if event.get('event') == "grid" and event.get('data').get('index') not in grid_events: + # grid_events[event.get('data').get('index')] = event.get('data') + # if event.get('event') == "play" and not play_index: + # play_index = event.get('data').get('index') + # if len(grid_events) == video_num and play_index: + # break + prev_grid_list = sorted([v for v in grid_events.values()], key=lambda k:k['index']) # if there were no grid events for all, initialize all grids.