minor additions to incorporate the future data scheme change

This commit is contained in:
pythagoraswitch 2018-07-25 16:07:31 +02:00
parent 29f892cafa
commit 83af674af9
1 changed files with 12 additions and 3 deletions

View File

@ -110,12 +110,13 @@ class Engine:
else:
# Once the "index" is added to play event data, played index will be excluded from the random shuffle
# and deterministically added to staySame pool.
# video_indx = [*range(playIndex)]+[*range(playIndex+1,video_num)]
video_indx = list(range(video_num))
random.shuffle(video_indx)
rec_list = []
# For now, randomly choose a clip in the same playlist instead of switching to the next clip.
# This will be changed once the clip position is tracked in the user data.
# This will be changed once the clip position is tracked in the user data as "playlistPostion"
for i in video_indx[:nc]:
if prev_grid_list[i].get('playlist') is None:
# add this to deal with the absence of "playlist" data in a grid event temporarily.
@ -124,24 +125,32 @@ class Engine:
nc = 0
break
else:
# if "playlist" data exists in grid event (it should be in the future)
# if "playlist" and "playlistPostion" data exists in grid event (it should be in the future)
for playlist in playlists:
if playlist.get('name')== prev_grid_list[i].get('playlist'):
# Discuss how this behavour should be: should it switch to a new playlist if it is the end of the playlist clip sequence already?
# if prev_grid_list[i].get('index') == len(playlist['clips']):
# playlist_pos = 0
# else:
# playlist_pos = prev_grid_list[i].get('index') + 1
rec_list.append((i, {
'clips': playlist['clips'],
'position': random.randrange(len(playlist['clips'])),
# 'position': playlist_pos,
'name': playlist['name'],
'tags': playlist['tags'],
}))
# randomly select playlists (excluding the playlists from the current grid once "playlist" is recorded for grid events)
# for nextPlaylist pool
# for nextPlaylist pool.
vids_exclude = []
# vids_exclude = [e.get("playlist") for e in prev_grid_list]
video = self.get_recommendations(user, vids_exclude)
rec_list += [(i, video[i]) for i in video_indx[nc:nc+np]]
#staySame pool
# video_indx.append(playIndex)
rec_list += [(i,{}) for i in video_indx[nc+np:]]
rec_list = sorted(rec_list, key=lambda k:k[0])