Commit e48ae2a4 authored by 段英荣's avatar 段英荣

Merge branch '2.3_relaces' into 'master'

用户点击个性化push进linucb

See merge request !472
parents f4d17441 fbba808c
...@@ -331,36 +331,43 @@ class CollectData(object): ...@@ -331,36 +331,43 @@ class CollectData(object):
else: else:
logging.warning("unknown type msg:%s" % raw_val_dict.get("type", "missing type")) logging.warning("unknown type msg:%s" % raw_val_dict.get("type", "missing type"))
# 用户点击个性化push进linucb # 用户点击个性化push进linucb
# elif "type" in raw_val_dict and raw_val_dict["type"] == "on_click_push": elif "type" in raw_val_dict and raw_val_dict["type"] == "on_click_push":
# if isinstance(raw_val_dict["params"]["tag_ids"], str): # 后端已过滤,该tag_ids是帖子/榜单的编辑标签
# tagid_list = json.loads(raw_val_dict["params"]["tag_ids"]) if "tag_ids" in raw_val_dict["params"]:
# elif isinstance(raw_val_dict["params"]["tag_ids"], list): tag_ids = raw_val_dict["params"]["tag_ids"]
# tagid_list = raw_val_dict["params"]["tag_ids"] else:
# else: # todo 客户端埋点bug,后期移除
# tagid_list = list() tag_ids = raw_val_dict["params"].get("tag_ids:", [])
# device_id = raw_val_dict["device"]["device_id"] if isinstance(tag_ids, str):
# user_id = raw_val_dict["user_id"] if "user_id" in raw_val_dict else None tagid_list = json.loads(tag_ids)
# if len(tagid_list) > 0: elif isinstance(tag_ids, list):
# tag_query_results = Tag.objects.using(settings.SLAVE_DB_NAME).filter( tagid_list = tag_ids
# id__in=tagid_list, is_online=True, is_deleted=False, else:
# is_category=False).values_list("id", flat=True) tagid_list = list()
# is_click = 1
# is_vote = 0 device_id = raw_val_dict["device"]["device_id"]
# reward = 1 if is_click or is_vote else 0 user_id = raw_val_dict["user_id"] if "user_id" in raw_val_dict else None
# for tag_id in tag_query_results: if len(tagid_list) > 0:
# self.update_user_linucb_tag_info(reward, device_id, tag_id, user_feature) tag_query_results = Tag.objects.using(settings.SLAVE_DB_NAME).filter(
# self.update_recommend_tag_list(device_id, user_feature, user_id, id__in=tagid_list, is_online=True, is_deleted=False,
# new_user_click_tag_list=tag_query_results) is_category=False).values_list("id", flat=True)
# logging.info("on_click_push topic type:%s, device_id:%s, answer_tag:%s" % is_click = 1
# (raw_val_dict.get("type", "missing type"), str(device_id), is_vote = 0
# str(tagid_list))) reward = 1 if is_click or is_vote else 0
for tag_id in tag_query_results:
self.update_user_linucb_tag_info(reward, device_id, tag_id, user_feature)
self.update_recommend_tag_list(device_id, user_feature, user_id,
new_user_click_tag_list=tag_query_results)
logging.info("on_click_push topic type:%s, device_id:%s, tag_ids:%s" %
(raw_val_dict.get("type", "missing type"), str(device_id),
str(tagid_list)))
# 用户点击问题清单进linucb # 用户点击问题清单进linucb
elif b'content' in raw_val_dict: elif b'content' in raw_val_dict:
data = json.loads(raw_val_dict[b'content']) data = json.loads(raw_val_dict[b'content'])
if 'SYS' in data and 'APP' in data and 'action' in data['SYS'] and data['SYS']['action'] == "venus/community/skin_check/submit_questions": if 'SYS' in data and 'APP' in data and 'action' in data['SYS'] and data['SYS']['action'] == "venus/community/skin_check/submit_questions":
device_id = data['SYS']['cl_id'] device_id = data['SYS']['cl_id']
tagid_list = list(data['APP']['answer_tag']) or [] tagid_list = list(data['APP'].get('answer_tag', []))
user_id = data['SYS']['user_id'] or None user_id = data['SYS'].get('user_id', None)
logging.info("skin_check topic type:%s, device_id:%s, answer_tag:%s" % logging.info("skin_check topic type:%s, device_id:%s, answer_tag:%s" %
(str(data['SYS']['action']), str(device_id), str(tagid_list))) (str(data['SYS']['action']), str(device_id), str(tagid_list)))
if len(tagid_list) > 0: if len(tagid_list) > 0:
......
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