|
@@ -2386,25 +2386,21 @@ class PoolRecall(object):
|
|
|
|
|
|
def get_3days_hot_item_reall(self, exp_config=None):
|
|
|
recall_key = "hot_3day:"
|
|
|
- #print("recall_key:", recall_key)
|
|
|
data = self.redis_helper.get_data_from_redis(key_name=recall_key)
|
|
|
-
|
|
|
- #print(data)
|
|
|
recall_result = []
|
|
|
recall_dict = {}
|
|
|
video_ids = []
|
|
|
- if data is not None:
|
|
|
- json_result = json.loads(data)
|
|
|
- #print("json_result:", json_result)
|
|
|
- for per_item in json_result:
|
|
|
- try:
|
|
|
- vid = int(per_item[0])
|
|
|
- video_ids.append(vid)
|
|
|
- recall_dict[vid] = {'videoId': vid, 'flowPool': '',
|
|
|
- 'rovScore': per_item[1], 'pushFrom': config_.PUSH_FROM['hot_3_day_recall'],
|
|
|
- 'abCode': self.ab_code}
|
|
|
- except Exception as e:
|
|
|
- continue
|
|
|
+ if data is not None and data!="":
|
|
|
+ try:
|
|
|
+ json_result = json.loads(data)
|
|
|
+ for per_item in json_result:
|
|
|
+ vid = int(per_item[0])
|
|
|
+ video_ids.append(vid)
|
|
|
+ recall_dict[vid] = {'videoId': vid, 'flowPool': '',
|
|
|
+ 'rovScore': per_item[1], 'pushFrom': config_.PUSH_FROM['hot_3_day_recall'],
|
|
|
+ 'abCode': self.ab_code}
|
|
|
+ except Exception as e:
|
|
|
+ return recall_result
|
|
|
#print("vid len:", len(video_ids))
|
|
|
if len(video_ids)<=0:
|
|
|
return recall_result
|
|
@@ -2434,23 +2430,20 @@ class PoolRecall(object):
|
|
|
recall_key = "hot_video:"
|
|
|
#print("recall_key:", recall_key)
|
|
|
data = self.redis_helper.get_data_from_redis(key_name=recall_key)
|
|
|
-
|
|
|
- #print(data)
|
|
|
recall_result = []
|
|
|
recall_dict = {}
|
|
|
video_ids = []
|
|
|
- if data is not None:
|
|
|
- json_result = json.loads(data)
|
|
|
- # print("json_result:", json_result)
|
|
|
- for per_item in json_result:
|
|
|
- try:
|
|
|
+ if data is not None and data!="":
|
|
|
+ try:
|
|
|
+ json_result = json.loads(data)
|
|
|
+ for per_item in json_result:
|
|
|
vid = int(per_item[0])
|
|
|
video_ids.append(vid)
|
|
|
recall_dict[vid] = {'videoId': vid, 'flowPool': '',
|
|
|
- 'rovScore': per_item[1], 'pushFrom': config_.PUSH_FROM['hot_recall'],
|
|
|
- 'abCode': self.ab_code}
|
|
|
- except Exception as e:
|
|
|
- continue
|
|
|
+ 'rovScore': per_item[1], 'pushFrom': config_.PUSH_FROM['hot_recall'],
|
|
|
+ 'abCode': self.ab_code}
|
|
|
+ except Exception as e:
|
|
|
+ recall_result
|
|
|
if len(video_ids)<=0:
|
|
|
return recall_result
|
|
|
recall_num = 20
|
|
@@ -2485,18 +2478,17 @@ class PoolRecall(object):
|
|
|
recall_result = []
|
|
|
recall_dict = {}
|
|
|
video_ids = []
|
|
|
- if data is not None:
|
|
|
- json_result = json.loads(data)
|
|
|
- # print("json_result:", json_result)
|
|
|
- for per_item in json_result:
|
|
|
- try:
|
|
|
- vid = int(per_item[0])
|
|
|
- video_ids.append(vid)
|
|
|
- recall_dict[vid] = {'videoId': vid, 'flowPool': '',
|
|
|
- 'rovScore': per_item[1], 'pushFrom': config_.PUSH_FROM['title_i2i_recall'],
|
|
|
- 'abCode': self.ab_code}
|
|
|
- except Exception as e:
|
|
|
- continue
|
|
|
+ if data is not None and data!="":
|
|
|
+ try:
|
|
|
+ json_result = json.loads(data)
|
|
|
+ for per_item in json_result:
|
|
|
+ vid = int(per_item[0])
|
|
|
+ video_ids.append(vid)
|
|
|
+ recall_dict[vid] = {'videoId': vid, 'flowPool': '',
|
|
|
+ 'rovScore': per_item[1], 'pushFrom': config_.PUSH_FROM['title_i2i_recall'],
|
|
|
+ 'abCode': self.ab_code}
|
|
|
+ except Exception as e:
|
|
|
+ return recall_result
|
|
|
if len(video_ids) <= 0:
|
|
|
return recall_result
|
|
|
video_ids = video_ids[:50]
|
|
@@ -2524,17 +2516,16 @@ class PoolRecall(object):
|
|
|
recall_dict = {}
|
|
|
video_ids = []
|
|
|
if data is not None and data.strip()!="":
|
|
|
- json_result = data.strip().split(",")
|
|
|
- # print("json_result:", json_result)
|
|
|
- for per_item in json_result:
|
|
|
- try:
|
|
|
- vid = int(per_item)
|
|
|
- video_ids.append(vid)
|
|
|
- recall_dict[vid] = {'videoId': vid, 'flowPool': '',
|
|
|
- 'rovScore': 0.0, 'pushFrom': config_.PUSH_FROM['w2v_recall'],
|
|
|
- 'abCode': self.ab_code}
|
|
|
- except Exception as e:
|
|
|
- continue
|
|
|
+ try:
|
|
|
+ json_result = data.strip().split(",")
|
|
|
+ for per_item in json_result:
|
|
|
+ vid = int(per_item)
|
|
|
+ video_ids.append(vid)
|
|
|
+ recall_dict[vid] = {'videoId': vid, 'flowPool': '',
|
|
|
+ 'rovScore': 0.0, 'pushFrom': config_.PUSH_FROM['w2v_recall'],
|
|
|
+ 'abCode': self.ab_code}
|
|
|
+ except Exception as e:
|
|
|
+ return recall_result
|
|
|
if len(video_ids)<=0:
|
|
|
return recall_result
|
|
|
recall_num = 20
|
|
@@ -2562,7 +2553,7 @@ class PoolRecall(object):
|
|
|
recall_key = "test_exp_config_pos"
|
|
|
# print("recall_key:", recall_key)
|
|
|
data = self.redis_helper.get_data_from_redis(key_name=recall_key)
|
|
|
- if data is not None:
|
|
|
+ if data is not None and data!="":
|
|
|
try:
|
|
|
#print(data)
|
|
|
json_result = json.loads(data)
|
|
@@ -2576,7 +2567,7 @@ class PoolRecall(object):
|
|
|
def get_w2v_config(self):
|
|
|
recall_key = "w2v_exp_config_pos_range"
|
|
|
data = self.redis_helper.get_data_from_redis(key_name=recall_key)
|
|
|
- if data is not None:
|
|
|
+ if data is not None and data!="":
|
|
|
try:
|
|
|
#print(data)
|
|
|
json_result = json.loads(data)
|
|
@@ -2606,7 +2597,7 @@ class PoolRecall(object):
|
|
|
recall_key = "simrecall_exp_config_range"
|
|
|
#print("recall_key:", recall_key)
|
|
|
data = self.redis_helper.get_data_from_redis(key_name=recall_key)
|
|
|
- if data is not None:
|
|
|
+ if data is not None and data!="":
|
|
|
try:
|
|
|
# print(data)
|
|
|
json_result = json.loads(data)
|
|
@@ -2632,9 +2623,9 @@ class PoolRecall(object):
|
|
|
return None
|
|
|
|
|
|
def get_U2I_config(self):
|
|
|
- recall_key = "u2i_exp_config_pos_range"
|
|
|
+ recall_key = "u2i_exp_config_pos_range_new"
|
|
|
data = self.redis_helper.get_data_from_redis(key_name=recall_key)
|
|
|
- if data is not None:
|
|
|
+ if data is not None and data!="":
|
|
|
try:
|
|
|
# print(data)
|
|
|
json_result = json.loads(data)
|
|
@@ -2734,18 +2725,17 @@ class PoolRecall(object):
|
|
|
recall_result = []
|
|
|
recall_dict = {}
|
|
|
video_ids = []
|
|
|
- if data is not None:
|
|
|
- json_result = json.loads(data)
|
|
|
- #print("json_result:", json_result)
|
|
|
- for per_item in json_result:
|
|
|
- try:
|
|
|
+ if data is not None and data!="":
|
|
|
+ try:
|
|
|
+ json_result = json.loads(data)
|
|
|
+ for per_item in json_result:
|
|
|
vid = int(per_item[0])
|
|
|
video_ids.append(vid)
|
|
|
recall_dict[vid] = {'videoId': vid, 'flowPool': '',
|
|
|
'rovScore': float(per_item[1]), 'pushFrom': config_.PUSH_FROM['u2i_tag_recall'],
|
|
|
'abCode': self.ab_code}
|
|
|
- except Exception as e:
|
|
|
- continue
|
|
|
+ except Exception as e:
|
|
|
+ return recall_result
|
|
|
if len(video_ids)<=0:
|
|
|
return recall_result
|
|
|
recall_num = 20
|
|
@@ -2819,7 +2809,7 @@ class PoolRecall(object):
|
|
|
def get_video_recall_config(self):
|
|
|
recall_key = "vr_exp_pos_config_range"
|
|
|
data = self.redis_helper.get_data_from_redis(key_name=recall_key)
|
|
|
- if data is not None:
|
|
|
+ if data is not None and data!="":
|
|
|
try:
|
|
|
# print(data)
|
|
|
json_result = json.loads(data)
|
|
@@ -2841,18 +2831,63 @@ class PoolRecall(object):
|
|
|
recall_result = []
|
|
|
recall_dict = {}
|
|
|
video_ids = []
|
|
|
- if data is not None:
|
|
|
- json_result = json.loads(data)
|
|
|
- #print("json_result:", json_result)
|
|
|
- for per_item in json_result:
|
|
|
- try:
|
|
|
+ if data is not None and data!="" :
|
|
|
+ try:
|
|
|
+ json_result = json.loads(data)
|
|
|
+ for per_item in json_result:
|
|
|
vid = int(per_item[0])
|
|
|
video_ids.append(vid)
|
|
|
recall_dict[vid] = {'videoId': vid, 'flowPool': '',
|
|
|
'rovScore': float(per_item[1]), 'pushFrom': config_.PUSH_FROM['return_video_recall'],
|
|
|
'abCode': self.ab_code}
|
|
|
- except Exception as e:
|
|
|
- continue
|
|
|
+ except Exception as e:
|
|
|
+ return recall_result
|
|
|
+ if len(video_ids)<=0:
|
|
|
+ return recall_result
|
|
|
+ recall_num = 20
|
|
|
+ try:
|
|
|
+ if exp_config and exp_config['recall_get_num']:
|
|
|
+ recall_num = int(exp_config['recall_get_num'])
|
|
|
+ except:
|
|
|
+ recall_num = 20
|
|
|
+ #print("recall_num:", recall_num)
|
|
|
+ video_ids = video_ids[:recall_num]
|
|
|
+ #print(video_ids)
|
|
|
+ filter_ = FilterVideos(request_id=self.request_id,
|
|
|
+ app_type=self.app_type, mid=self.mid, uid=self.uid, video_ids=video_ids)
|
|
|
+ filtered_viewed_videos = filter_.filter_videos_status(pool_type='normal')
|
|
|
+ if filtered_viewed_videos is None:
|
|
|
+ return recall_result
|
|
|
+ #print("filtered_viewed_videos:", filtered_viewed_videos)
|
|
|
+ for vid in filtered_viewed_videos:
|
|
|
+ if vid in recall_dict:
|
|
|
+ recall_result.append(recall_dict[vid])
|
|
|
+ #print("u2i recall_result:", recall_result)
|
|
|
+ return recall_result
|
|
|
+
|
|
|
+ def get_play_reall(self, mid, exp_config=None):
|
|
|
+ #recall_key = "hot_video:"
|
|
|
+ if not mid:
|
|
|
+ return []
|
|
|
+ recall_key = "u2i_play:"+mid
|
|
|
+ #print("recall_key:", recall_key)
|
|
|
+ data = self.redis_helper.get_data_from_redis(key_name=recall_key)
|
|
|
+
|
|
|
+ #print(data)
|
|
|
+ recall_result = []
|
|
|
+ recall_dict = {}
|
|
|
+ video_ids = []
|
|
|
+ if data is not None and data!="":
|
|
|
+ try:
|
|
|
+ json_result = json.loads(data)
|
|
|
+ for per_item in json_result:
|
|
|
+ vid = int(per_item[0])
|
|
|
+ video_ids.append(vid)
|
|
|
+ recall_dict[vid] = {'videoId': vid, 'flowPool': '',
|
|
|
+ 'rovScore': float(per_item[1]), 'pushFrom': config_.PUSH_FROM['u2i_tag_play_recall'],
|
|
|
+ 'abCode': self.ab_code}
|
|
|
+ except Exception as e:
|
|
|
+ return recall_result
|
|
|
if len(video_ids)<=0:
|
|
|
return recall_result
|
|
|
recall_num = 20
|