minor additions to incorporate the future data scheme change
This commit is contained in:
parent
29f892cafa
commit
83af674af9
1 changed files with 12 additions and 3 deletions
|
@ -110,12 +110,13 @@ class Engine:
|
||||||
else:
|
else:
|
||||||
# Once the "index" is added to play event data, played index will be excluded from the random shuffle
|
# Once the "index" is added to play event data, played index will be excluded from the random shuffle
|
||||||
# and deterministically added to staySame pool.
|
# and deterministically added to staySame pool.
|
||||||
|
|
||||||
# video_indx = [*range(playIndex)]+[*range(playIndex+1,video_num)]
|
# video_indx = [*range(playIndex)]+[*range(playIndex+1,video_num)]
|
||||||
video_indx = list(range(video_num))
|
video_indx = list(range(video_num))
|
||||||
random.shuffle(video_indx)
|
random.shuffle(video_indx)
|
||||||
rec_list = []
|
rec_list = []
|
||||||
# For now, randomly choose a clip in the same playlist instead of switching to the next clip.
|
# 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]:
|
for i in video_indx[:nc]:
|
||||||
if prev_grid_list[i].get('playlist') is None:
|
if prev_grid_list[i].get('playlist') is None:
|
||||||
# add this to deal with the absence of "playlist" data in a grid event temporarily.
|
# add this to deal with the absence of "playlist" data in a grid event temporarily.
|
||||||
|
@ -124,24 +125,32 @@ class Engine:
|
||||||
nc = 0
|
nc = 0
|
||||||
break
|
break
|
||||||
else:
|
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:
|
for playlist in playlists:
|
||||||
if playlist.get('name')== prev_grid_list[i].get('playlist'):
|
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, {
|
rec_list.append((i, {
|
||||||
'clips': playlist['clips'],
|
'clips': playlist['clips'],
|
||||||
'position': random.randrange(len(playlist['clips'])),
|
'position': random.randrange(len(playlist['clips'])),
|
||||||
|
# 'position': playlist_pos,
|
||||||
'name': playlist['name'],
|
'name': playlist['name'],
|
||||||
'tags': playlist['tags'],
|
'tags': playlist['tags'],
|
||||||
}))
|
}))
|
||||||
|
|
||||||
# randomly select playlists (excluding the playlists from the current grid once "playlist" is recorded for grid events)
|
# 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 = []
|
||||||
# vids_exclude = [e.get("playlist") for e in prev_grid_list]
|
# vids_exclude = [e.get("playlist") for e in prev_grid_list]
|
||||||
video = self.get_recommendations(user, vids_exclude)
|
video = self.get_recommendations(user, vids_exclude)
|
||||||
rec_list += [(i, video[i]) for i in video_indx[nc:nc+np]]
|
rec_list += [(i, video[i]) for i in video_indx[nc:nc+np]]
|
||||||
|
|
||||||
#staySame pool
|
#staySame pool
|
||||||
|
# video_indx.append(playIndex)
|
||||||
rec_list += [(i,{}) for i in video_indx[nc+np:]]
|
rec_list += [(i,{}) for i in video_indx[nc+np:]]
|
||||||
|
|
||||||
rec_list = sorted(rec_list, key=lambda k:k[0])
|
rec_list = sorted(rec_list, key=lambda k:k[0])
|
||||||
|
|
Loading…
Reference in a new issue