removed the outdated portion: screening parameter etc

This commit is contained in:
pythagoraswitch 2018-09-26 23:56:29 +02:00
parent 024c1008fb
commit 81cfe9c9d8
1 changed files with 2 additions and 20 deletions

View File

@ -45,7 +45,6 @@ class Engine:
'channels': {
'globalKeywords': {'locked': False, 'value': 8},
'userKeywords': {'locked': False, 'value': 8}
# 'screenings': {'locked': True, 'value': 2}
},
'globalKeywords': {},
}
@ -202,8 +201,7 @@ class Engine:
}
# NOTE for future improvement: vids_exclude element unit could be clip or in/out time pairs, rather than playlist.
# The same playlist could be played in the grid view as long as these are differenct clips or separate times.
def get_recommendations(self, user, vids_exclude = []):
channels = {k: v.get('value', 0) for k, v in self.state['channels'].items()}
sliders = {k: v.get('value', 0) for k, v in self.state['globalKeywords'].items()}
@ -255,23 +253,7 @@ class Engine:
playlists,
key=lambda playlist: -score[playlist['name']]
)
videos += playlists[:channels['globalKeywords']]
playlists = playlists[channels['globalKeywords']:]
# Count products the user has seen
count = defaultdict(lambda: 0)
for event in user.get('events', []):
if event.get('data', {}).get('product'):
count[event['data']['product']] += 1
# For each product in playlist tags, increment score by count
for playlist in playlists:
score[playlist['name']] = random.random()
for tag in set(playlist['tags']) & set(count):
score[playlist['name']] += count[tag]
# Select highest scoring playlists
videos += sorted(
playlists,
key=lambda playlist: -score[playlist['name']]
)[:16 - channels['userKeywords'] - channels['globalKeywords']]
videos += playlists[:16 - channels['userKeywords']]
# Shuffle playlists (randomize layout) and shift clips (randomize start)
random.shuffle(videos)
return [{