Commit 04ec8e6e authored by 高雅喆's avatar 高雅喆

lin榜单已读灰度实验

parent 85ab77fa
......@@ -254,7 +254,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
return [], []
def get_home_recommend_pictorial_ids(user_id=-1, device_id="", size=4):
def get_home_recommend_pictorial_ids(user_id=-1, device_id="", size=4, is_gray=-1):
try:
pictorial_recommend_redis_key = "physical:linucb:pictorial_recommend:device_id:" + str(device_id)
have_read_lin_pictorial_id_list = get_have_read_lin_pictorial_id_list(device_id, user_id,
......@@ -278,9 +278,12 @@ def get_home_recommend_pictorial_ids(user_id=-1, device_id="", size=4):
redis_field_list = 'have_read_pictorial_list'
redis_client.hset(redis_key, redis_field_list, have_read_lin_pictorial_id_list)
today = datetime.datetime.strptime(str(datetime.date.today()), "%Y-%m-%d")
tomorrow = today + datetime.timedelta(days=1)
if is_gray == 0:
end_day = today + datetime.timedelta(days=10)
else:
end_day = today + datetime.timedelta(days=1)
nowTime = datetime.datetime.now()
expire_time = (tomorrow - nowTime).seconds + 3 * 60 * 60
expire_time = (end_day - nowTime).seconds + 3 * 60 * 60
redis_client.expire(redis_key, expire_time)
return recommend_pictorial_ids
else:
......@@ -412,7 +415,7 @@ def home_recommend(device_id="", user_id=-1, offset=0, lin_pictorial_count=4, si
else:
if usefulrecall != -1 and len(useful_tag_list) > 0:
recommend_pictorial_ids = get_home_recommend_pictorial_ids(user_id, device_id, lin_pictorial_count)
recommend_pictorial_ids = get_home_recommend_pictorial_ids(user_id, device_id, lin_pictorial_count, is_gray=is_gray)
size = size - len(recommend_pictorial_ids)
if is_debug:
has_score = True
......@@ -448,7 +451,7 @@ def home_recommend(device_id="", user_id=-1, offset=0, lin_pictorial_count=4, si
"debug_model_data": results}
else:
recommend_pictorial_ids = get_home_recommend_pictorial_ids(user_id, device_id, lin_pictorial_count)
recommend_pictorial_ids = get_home_recommend_pictorial_ids(user_id, device_id, lin_pictorial_count, is_gray=is_gray)
size = size - len(recommend_pictorial_ids)
if is_debug:
has_score = True
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment