Commit 64362734 authored by 王丽丹's avatar 王丽丹

Merge branch 'mr/develop/020100' into 'mr/develop/dbmw'

Mr/develop/020100

See merge request !57
parents ec1db7b5 7d6cafb6
......@@ -10,12 +10,15 @@ from tags.services.tag import (get_tagv3_analysis_info, get_tag_v3_operators_tag
get_tag_v3_gossip_tag_ids)
from talos.services.convert_service.user_convert_service import UserConvertService
from data_sync.tractate.transfer import get_keynote_sentence
from gm_types.gaia import DOCTOR_TYPE
from gm_types.gaia import DOCTOR_TYPE, TAG_TYPE
from talos.services.doctor import DoctorService
import time
import datetime
from django.conf import settings
import redis
import logging
from algorithm.text_classifical.base import model as alo_model
from gm_types.doris import SELECTED_CONTENT_TYPE
rpc = get_rpc_invoker()
......@@ -38,8 +41,6 @@ def get_answers(pks):
item['doctor_id'] = DoctorService.get_doctor_by_user_id_v1(answer.user_id)
item['question_id'] = answer.question.id
item['smart_rank'] = answer.smart_rank()
item['smart_rank_v2'] = answer.smart_rank_v2()
item['smart_rank_v3'] = answer.smart_rank_v3()
item['title'] = answer.question.title
item['desc'] = answer.question.content
item['question_type'] = answer.question.question_type
......@@ -60,8 +61,13 @@ def get_answers(pks):
item['new_smr'] = answer.get_new_smart_rank_score(answer_id=answer.id)
score = answer.get_search_new_smart_rank_score(answer_id=answer.id)
item['search_new_smr'] = score.get("smart_rank_score", 0)
item['new_goodclicks'] = score.get('new_goodclick', 0)
item['detail_smr'] = score.get('smart_rank_v2', 0)
# community_score = answer.get_community_answer_smr_score(answer.id)
community_hot_score = answer.get_community_answer_hot_score(answer.id)
item['new_goodclicks'] = community_hot_score.get('hot_score', 0)
item['smart_rank_v2'] = answer.get_new_smart_rank_score(answer_id=answer.id)
item['smart_rank_v3'] = answer.get_new_smart_rank_score(answer_id=answer.id)
item['platform'] = answer.platform
# 新标签
fresh_tag_result = rpc["api/agile_tag/tuple_new_tags"](old_tag_ids=tags_id_list)
......@@ -93,7 +99,6 @@ def get_answers(pks):
item['operators_add_tags'] = get_tag_v3_operators_tags(content_id=answer.id, content_type="answer")
item['anecdote_tags'] = get_tag_v3_anecdote_tags(content_id=answer.id, content_type="answer")
item['anecdote_tag_ids'] = get_tag_v3_anecdote_tag_ids(content_id=answer.id, content_type="answer")
item['show_by_index'] = answer.get_answer_show_by_index(answer.id)
(need_refresh_data, second_demands_list, second_solutions_list, second_positions_list,
second_demands_ids_list,
......@@ -191,7 +196,75 @@ def get_answers(pks):
item["gossip_tag_ids"] = get_tag_v3_gossip_tag_ids(content_id=answer.id, content_type="answer")
item["gossip_tags"] = get_tag_v3_gossip_tag_ids(content_id=answer.id, content_type="answer", get_names=True)
# 首页精选增加内容分类 明星列表和网红列表
tagv4 = answer.get_answer_tagv4_names(answer_id=answer.id)
if tagv4:
tags_info = answer.get_answer_tag(tagv4)
item['selected_stars'] = []
item['selected_internet_celebrity'] = []
all_tags = []
for tag in tags_info:
all_tags.append(tag.get("id", None))
if tag.get("tag_type", 0) == TAG_TYPE.STAR:
item['selected_stars'].append(tag.get("name", None))
elif tag.get("tag_type", 0) == TAG_TYPE.INFLUENCER:
item['selected_internet_celebrity'].append(tag.get("name", None))
else:
pass
if tag.get("id") == 14288:
item['operators_add_tags'].append(14288)
if 15928 in all_tags:
item['selected_content_type'] = SELECTED_CONTENT_TYPE.BEAUTY_STAR
elif 10682 in all_tags:
item['selected_content_type'] = SELECTED_CONTENT_TYPE.STAR_GOSSIP
elif 15930 in all_tags:
item['selected_content_type'] = SELECTED_CONTENT_TYPE.BEAUTY_CELEBRITY
elif 10683 in all_tags:
item['selected_content_type'] = SELECTED_CONTENT_TYPE.CELEBRITY_GOSSIP
else:
item['selected_content_type'] = -1
else:
try:
result_data = alo_model.run(answer.content)
item['selected_content_type'] = int(result_data.get("content_type", 0))
item['selected_internet_celebrity'] = [list(item.keys())[0] for item in
result_data.get("celebrity", [])]
item['selected_stars'] = [list(item.keys())[0] for item in result_data.get("star", [])]
projects = [list(item.keys())[0] for item in result_data.get("projects", [])]
item['portrait_tag_name'].extend(projects)
except:
pass
if 3315 in item['operators_add_tags']:
item['new_smr'] = answer.get_answer_newuser_smr(answer_id=answer.id)
answer_all_tag_names = list()
filter_tags_names = ["假体隆胸", "自体脂肪隆胸", "胶原蛋白填充隆胸", "玻尿酸填充隆胸", "胸部假体取出",
"胸部失败修复", "胸部下垂矫正", "胸部修复", "胸形美化", "丰胸(隆胸)", "胸部塑身", "玻尿酸隆胸", "假体隆胸", "胶原蛋白隆胸",
"埋线隆胸", "自体脂肪隆胸", "胸部注射物取出", "胸部假体取出", "胸部假体取出", "胸部修复", "脂肪胶隆胸", "胸部整形", "隆胸", "胸部美化",
"缩胸", "胸部提升", "生胸毛", "胸部护理", "综合隆胸", "植胸毛", "胸部修复", "隆胸修复", "胸部护理", "硅胶隆胸", "胸部护理",
"胸部修复", "胸部手术", "胸部提升", "生胸毛", "美胸", "胸毛", "胸部", "胸形", "胸部假体", "胸部kyc", "自体脂肪丰胸",
"泰国隆胸", "泰国假体隆胸", "脂肪丰胸", "复合式隆胸", "隆胸假体", "丰胸(隆胸)", "美胸养成", "在线面诊 美胸名医", "为男友隆胸",
"手术隆胸", "美胸创造营", "隆胸手术", "隆胸丰胸", "胸部下垂", '手术隆胸', "隆胸丰胸", "假体隆胸 成都罗通贵", "丰胸隆胸", "美胸套餐",
"美胸护理", "自体脂肪填充胸部", "自体隆胸","处女膜修复","手术祛副乳","吸脂祛副乳","阴茎延长","包皮手术","阴茎增大","阴道成形","自体脂肪填充阴唇","女性私密检查","阴唇漂红","G点注射","激光脱私处毛发","乳头缩小","手术紧缩阴道","激光紧缩阴道","私密整形","私密脱毛","私密清洁","阴唇美化","阴道美化","阴蒂美化","处女膜修复","处女膜","女性高潮","阴茎美化","女性私密","私密护理","自体脂肪私密紧致","盆底修复","植私密毛发","阴道紧缩","私密清洁","阴道修复","阴唇整形","阴蒂整形","私密紧致","私密修复","玻尿酸丰阴唇","胶原蛋白丰阴唇","私密kyc","阴道松弛","阴蒂","阴道","处女膜","私密美化","阴蒂美化","阴茎美化","阴道成形","私密紧致","漂红","私密手术","男性私密","女性私密","脱私密毛发","缩阴道激光","生私密毛发","私密健康","阴道修复","生殖系统","女性私处","男性私处","阴茎","阴唇","处女膜","私密部位","胸形","乳晕","乳头","乳腺","副乳","私密护理","悦升私密紧收线","私密整形","私密其他","处女膜修复","阴道紧缩","阴道成形","包皮手术","填充阴唇","阴蒂肥大整形","阴唇整形","私密其他项目","阴蒂提升","小阴唇整形","阴茎延长","阴茎增粗","女性私密","男性私密","切开缝合法缩紧阴道","激光紧缩阴道","女性私密保养品","女性私密处保养","D女郎缩阴产品","私密整形1","私处整形","激光脱比基尼部位","私密回春术","缩阴术","激光脱比基尼","缩阴","私处护理","私处紧致","私密超声提升.","阴蒂整形","激光阴道紧缩术"]
operators_add_tags_names = list()
operators_add_tags_names = get_tag_v3_names_by_tag_v3_ids(item['operators_add_tags'])
answer_all_tag_names.extend(item["tags_v3"] + item["first_demands"] + item["second_demands"] + item[
"first_solutions"] + item["second_solutions"] + item["positions"] + item["second_positions"] + item[
'tag_name'] + item['fresh_tag_name'] + item["operators_add_tags"] + item[
"anecdote_tags"] + item["portrait_tag_name"] + item['gossip_tags'] + item[
'second_classify_names'] + item[
'first_classify_names'] + operators_add_tags_names)
tags_inter = [item for item in list(set(answer_all_tag_names)) if item in list(set(filter_tags_names))]
if tags_inter:
item['show_by_index'] = 2 # 2 标签中含有过滤列表中的标签
else:
item['show_by_index'] = answer.get_answer_show_by_index(answer.id)
data.append(item)
logging.info("get data:%s" % data)
except (Answer.DoesNotExist, Question.DoesNotExist):
pass
......
......@@ -30,7 +30,7 @@ def get_live_stream(pks):
user_id = user_id_id.id
item["doctor_id"] = DoctorService.get_doctor_by_user_id_v1(user_id)
item["user_id"] = user_id
item["is_online"] = live.is_finish
item["is_online"] = True if live.is_finish else False
item["principal_type"] = 1
try:
start_time = tzlc(live.created_time)
......@@ -43,13 +43,13 @@ def get_live_stream(pks):
item["show_order"] = 999
item["article_type"] = None
item["status"] = None
item["live_status"] = live.status
item["hera_is_online"] = None
item["live_status"] = True if live.status else False
item["hera_is_online"] = False
item["topic_isnull"] = True if live.topic else False
item["topic_is_online"] = live.get_topic_is_online()
item['is_test'] = live.is_test
item['is_shouyejingxuan'] = 0
item['is_show'] = live.is_show
item["topic_is_online"] = True if live.get_topic_is_online() else False
item['is_test'] = True if live.is_test else False
item['is_shouyejingxuan'] = False
item['is_show'] = True if live.is_show else False
item['stick_status'] = live.stick_status
item['stick_timestamp'] = live.stick_timestamp
us = UserService()
......@@ -91,7 +91,7 @@ def get_live_notice(pks):
item["id"] = notice.id
item["doctor_id"] = DoctorService.get_doctor_by_user_id_v1(notice.anchor_user_id)
item["user_id"] = notice.anchor_user_id
item["is_online"] = notice.is_online
item["is_online"] = True if notice.is_online else False
item["principal_type"] = 3
try:
start_time = tzlc(notice.start_time)
......@@ -102,15 +102,15 @@ def get_live_notice(pks):
item["zhibo_time"] = int(time.mktime(zhibo_time.timetuple()))
except:
pass
item['is_shouyejingxuan'] = notice.is_shouyejingxuan
item['is_shouyejingxuan'] = True if notice.is_shouyejingxuan else False
item["show_order"] = 999
item["article_type"] = None
item["status"] = None
item["live_status"] = None
item["hera_is_online"] = None
item["topic_isnull"] = None
item["topic_is_online"] = None
item['is_show'] = 1
item["live_status"] = False
item["hera_is_online"] = False
item["topic_isnull"] = False
item["topic_is_online"] = False
item['is_show'] = True
data.append(item)
logging.info("get data:%s" % data)
......@@ -127,26 +127,25 @@ def get_activity(pks):
item["id"] = activity.id
item["doctor_id"] = activity.doctor_id
item["user_id"] = ''
item["is_online"] = activity.is_online
item["is_online"] = True if activity.is_online else False
item["principal_type"] = 2
try:
start_time = tzlc(activity.start_time)
item["start_time"] = int(time.mktime(start_time.timetuple()))
end_time = tzlc(activity.end_time)
item["end_time"] = int(time.mktime(end_time.timetuple()))
except:
pass
item["zhibo_time"] = None
item["show_order"] = 999
item["article_type"] = None
item["status"] = None
item["live_status"] = None
item["hera_is_online"] = None
item["topic_isnull"] = None
item["topic_is_online"] = None
item['is_shouyejingxuan'] = 0
item['is_show'] = 1
item["live_status"] = False
item["hera_is_online"] = False
item["topic_isnull"] = False
item["topic_is_online"] = False
item['is_shouyejingxuan'] = False
item['is_show'] = True
data.append(item)
logging.info("get data:%s" % data)
......@@ -163,7 +162,7 @@ def get_video_tractate(pks):
item["id"] = softarticle.id
item["doctor_id"] = softarticle.doctor_id
item["user_id"] = ""
item["is_online"] = softarticle.is_online
item["is_online"] = True if softarticle.is_online else False
item["principal_type"] = 4
try:
start_time = tzlc(softarticle.create_time)
......@@ -175,12 +174,12 @@ def get_video_tractate(pks):
item["show_order"] = softarticle.show_order
item["article_type"] = softarticle.article_type
item["status"] = softarticle.status
item["live_status"] = None
item["hera_is_online"] = softarticle.hera_is_online
item["topic_isnull"] = None
item["topic_is_online"] = None
item['is_shouyejingxuan'] = 0
item['is_show'] = 1
item["live_status"] = False
item["hera_is_online"] = True if softarticle.hera_is_online else False
item["topic_isnull"] = False
item["topic_is_online"] = False
item['is_shouyejingxuan'] = False
item['is_show'] = True
data.append(item)
logging.info("get data:%s" % data)
......@@ -197,7 +196,7 @@ def get_word_tractate(pks):
item["id"] = softarticle.id
item["doctor_id"] = softarticle.doctor_id
item["user_id"] = ""
item["is_online"] = softarticle.is_online
item["is_online"] = True if softarticle.is_online else False
item["principal_type"] = 5
try:
start_time = tzlc(softarticle.create_time)
......@@ -209,12 +208,12 @@ def get_word_tractate(pks):
item["show_order"] = softarticle.show_order
item["article_type"] = softarticle.article_type
item["status"] = softarticle.status
item["live_status"] = None
item["hera_is_online"] = softarticle.hera_is_online
item["topic_isnull"] = None
item["topic_is_online"] = None
item['is_shouyejingxuan'] = 0
item['is_show'] = 1
item["live_status"] = False
item["hera_is_online"] = True if softarticle.hera_is_online else False
item["topic_isnull"] = False
item["topic_is_online"] = False
item['is_shouyejingxuan'] = False
item['is_show'] = True
data.append(item)
logging.info("get data:%s" % data)
......@@ -234,7 +233,7 @@ def get_article(pks):
item["user_id"] = article.user_id
item["doctor_id"] = UserService.get_doctor_id_from_user_id(article.user_id)
logging.info("get doctor_id:%s" % item["doctor_id"])
item["is_online"] = article.is_online
item["is_online"] = True if article.is_online else False
item["principal_type"] = 6
try:
start_time = tzlc(article.created_time)
......@@ -246,12 +245,12 @@ def get_article(pks):
item["show_order"] = 999
item["article_type"] = None
item["status"] = None
item["live_status"] = None
item["hera_is_online"] = None
item["topic_isnull"] = None
item["topic_is_online"] = None
item['is_shouyejingxuan'] = 0
item['is_show'] = 1
item["live_status"] = False
item["hera_is_online"] = False
item["topic_isnull"] = False
item["topic_is_online"] = False
item['is_shouyejingxuan'] = False
item['is_show'] = True
data.append(item)
logging.info("get data:%s" % data)
......
......@@ -20,6 +20,8 @@ from django.conf import settings
import redis
import re
import traceback
from algorithm.text_classifical.base import model as alo_model
from gm_types.doris import SELECTED_CONTENT_TYPE
def get_tractate(pks):
......@@ -201,7 +203,24 @@ def get_tractate(pks):
# item["is_need_guarantee"] = False
# 过滤标签
filter_tags_names = ["斩男心机妆", "今日look打卡", "少女心未泯", "颜值高光时刻", "美妆", "Get漫画迷人眼", "最显白口红推荐", "口红试色", "穿搭技巧",
"眼妆教程", "腮红", "氧气笑容练成记", "口红试色"]
"眼妆教程", "腮红", "氧气笑容练成记", "口红试色","假体隆胸", "自体脂肪隆胸", "胶原蛋白填充隆胸", "玻尿酸填充隆胸", "胸部假体取出",
"胸部失败修复", "胸部下垂矫正", "胸部修复", "胸形美化", "丰胸(隆胸)", "胸部塑身", "玻尿酸隆胸", "假体隆胸", "胶原蛋白隆胸",
"埋线隆胸", "自体脂肪隆胸", "胸部注射物取出", "胸部假体取出", "胸部假体取出", "胸部修复", "脂肪胶隆胸", "胸部整形", "隆胸", "胸部美化",
"缩胸", "胸部提升", "生胸毛", "胸部护理", "综合隆胸", "植胸毛", "胸部修复", "隆胸修复", "胸部护理", "硅胶隆胸", "胸部护理",
"胸部修复", "胸部手术", "胸部提升", "生胸毛", "美胸", "胸毛", "胸部", "胸形", "胸部假体", "胸部kyc", "自体脂肪丰胸",
"泰国隆胸", "泰国假体隆胸", "脂肪丰胸", "复合式隆胸", "隆胸假体", "丰胸(隆胸)", "美胸养成", "处女膜修复", "手术祛副乳", "吸脂祛副乳",
"阴茎延长", "包皮手术", "阴茎增大", "阴道成形", "自体脂肪填充阴唇", "女性私密检查", "阴唇漂红", "G点注射", "激光脱私处毛发",
"乳头缩小", "手术紧缩阴道", "激光紧缩阴道", "私密整形", "私密脱毛", "私密清洁", "阴唇美化", "阴道美化", "阴蒂美化", "处女膜修复",
"处女膜", "女性高潮", "阴茎美化", "女性私密", "私密护理", "自体脂肪私密紧致", "盆底修复", "植私密毛发", "阴道紧缩", "私密清洁",
"阴道修复", "阴唇整形", "阴蒂整形", "私密紧致", "私密修复", "玻尿酸丰阴唇", "胶原蛋白丰阴唇", "私密kyc", "阴道松弛", "阴蒂",
"阴道", "处女膜", "私密美化", "阴蒂美化", "阴茎美化", "阴道成形", "私密紧致", "漂红", "私密手术", "男性私密", "女性私密",
"脱私密毛发", "缩阴道激光", "生私密毛发", "私密健康", "阴道修复", "生殖系统", "女性私处", "男性私处", "阴茎", "阴唇", "处女膜",
"私密部位", "胸形", "乳晕", "乳头", "乳腺", "副乳", "私密护理", "悦升私密紧收线", "私密整形", "私密其他", "处女膜修复",
"阴道紧缩", "阴道成形", "包皮手术", "填充阴唇", "阴蒂肥大整形", "阴唇整形", "私密其他项目", "阴蒂提升", "小阴唇整形", "阴茎延长",
"阴茎增粗", "女性私密", "男性私密", "切开缝合法缩紧阴道", "激光紧缩阴道", "女性私密保养品", "女性私密处保养", "D女郎缩阴产品",
"私密整形1", "私处整形", "激光脱比基尼部位", "私密回春术", "缩阴术", "激光脱比基尼", "缩阴", "私处护理", "私处紧致", "私密超声提升.",
"阴蒂整形", "激光阴道紧缩术" ]
operators_add_tags_names = list()
operators_add_tags_names = get_tag_v3_names_by_tag_v3_ids(item['operators_add_tags'])
tractate_all_tag_names.extend(
......@@ -212,11 +231,13 @@ def get_tractate(pks):
+ item['channel_tags_names'] + item['anecdote_tags'] + item["first_classify_names"] + item[
"second_classify_names"] + operators_add_tags_names)
tags_inter = list(set(tractate_all_tag_names).intersection(set(filter_tags_names)))
tags_inter = [item for item in list(set(tractate_all_tag_names)) if item in list(set(filter_tags_names))]
# tags_inter = list(set(tractate_all_tag_names).intersection(set(filter_tags_names)))
if tags_inter:
item['show_by_index'] = 2 # 2 标签中含有过滤列表中的标签
else:
item['show_by_index'] = tractate.get_show_by_index(tractate.id)
item["has_video"] = TractateService.has_video(tractate.id)
item["is_gif"] = tractate.cover_is_dynamic # 是否是动图
# 判断是否有八卦标签
......@@ -230,8 +251,53 @@ def get_tractate(pks):
item["gossip_tags"] = get_tag_v3_gossip_tag_ids(content_id=tractate.id, content_type="tractate",
get_names=True)
data.append(item)
# 首页精选增加内容分类 明星列表和网红列表
tagv4 = tractate.get_tractate_tagv4_names(tractate_id=tractate.id)
if tagv4:
tags_info = tractate.get_tag(list(tagv4))
item['selected_stars'] = []
item['selected_internet_celebrity'] = []
all_tags = []
for tag in tags_info:
all_tags.append(tag.get("id", None))
if tag.get("tag_type", 0) == TAG_TYPE.STAR:
item['selected_stars'].append(tag.get("name", None))
elif tag.get("tag_type", 0) == TAG_TYPE.INFLUENCER:
item['selected_internet_celebrity'].append(tag.get("name", None))
else:
pass
if tag.get("id") == 14288:
item['operators_add_tags'].append(14288)
if 15928 in all_tags:
item['selected_content_type'] = SELECTED_CONTENT_TYPE.BEAUTY_STAR
elif 10682 in all_tags:
item['selected_content_type'] = SELECTED_CONTENT_TYPE.STAR_GOSSIP
elif 15930 in all_tags:
item['selected_content_type'] = SELECTED_CONTENT_TYPE.BEAUTY_CELEBRITY
elif 10683 in all_tags:
item['selected_content_type'] = SELECTED_CONTENT_TYPE.CELEBRITY_GOSSIP
else:
item['selected_content_type'] = -1
else:
try:
result_data = alo_model.run(tractate.content)
item['selected_content_type'] = int(result_data.get("content_type", 0))
item['selected_internet_celebrity'] = [list(item.keys())[0] for item in
result_data.get("celebrity", [])]
item['selected_stars'] = [list(item.keys())[0] for item in result_data.get("star", [])]
projects = [list(item.keys())[0] for item in result_data.get("projects", [])]
item['portrait_tag_name'].extend(projects)
except:
pass
if "operators_add_tags" in item and 3315 in item['operators_add_tags']:
item['new_smr'] = tractate.get_tractate_newuser_smr(tractate_id=tractate.id)
# 新增V4社区运营标签
item["operate_tags_v4"] = list(tagv4)
data.append(item)
logging.info("get data:%s" % data)
return data
except:
......
......@@ -617,6 +617,26 @@ class LiveStream(models.Model):
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return None
def allow_city(self, hospital_id_city, stream_id):
try:
all_city_id = []
##获取医生对应的城市ID
if hospital_id_city:
all_city_id.append(hospital_id_city)
##获取关联美购对应的城市ID
service_id = list(LiveStreamService.objects.filter(stream_id=stream_id, is_deleted=False).values_list(
"service_id", flat=True))
service_info = GoodsService.get_diary_show_info_by_service_ids(service_ids=service_id)
for key, values in service_info.items():
city_tag_id = values.get("city_tag_id", None)
if city_tag_id:
all_city_id.append(city_tag_id)
return list(set(all_city_id))
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return []
class LiveStreamTag(models.Model):
class Meta:
......
......@@ -388,9 +388,12 @@ class QuestionTag(models.Model):
return name
def get_project_tags(self, tag_list):
try:
tag_list = TagService._get_by_ids_from_cache_type(list(tag_list))
return [t.name for t in tag_list if
t.tag_type in (TAG_TYPE.BODY_PART, TAG_TYPE.BODY_PART_SUB_ITEM, TAG_TYPE.ITEM_WIKI)]
except:
return []
class QuestionTagV3(models.Model):
......@@ -1013,12 +1016,25 @@ class Answer(models.Model):
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return 0
def get_answer_newuser_smr(self, answer_id):
score = SrategyAnswerSmrScore.objects.using(settings.DORIS_DB_NAME).filter(
answer_id=answer_id).order_by('-create_date').values_list("smart_rank_score", flat=True).first()
if score:
return score
else:
return 0
def get_answer_tagv4_names(self, answer_id):
try:
data = AnswerTagV4.objects.using(settings.HERA_READ_DB).filter(answer_id=answer_id).values_list(
"tag_v4_id", flat=True)
return data
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return []
def get_search_new_smart_rank_score(self, answer_id):
try:
today = datetime.datetime.now().date()
delta = datetime.timedelta(days=1)
n_days = today - delta
date_change = str(n_days).replace("-", "")
score = SearchStrategyAnswerSmrScore.objects.using(settings.DORIS_DB_NAME).filter(
answer_id=answer_id).order_by('-create_date').values("smart_rank_score", "new_goodclick",
"smart_rank_v2").first()
......@@ -1030,6 +1046,30 @@ class Answer(models.Model):
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {}
def get_community_answer_smr_score(self, answer_id):
try:
score = CommunitysStrategyAnswerSmrScore.objects.using(settings.DORIS_DB_NAME).filter(
answer_id=answer_id).order_by('-create_date').values("smart_rank_score").first()
if score:
return score
else:
return {}
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {}
def get_community_answer_hot_score(self, answer_id):
try:
score = CommunitysStrategyAnswerHotScore.objects.using(settings.DORIS_DB_NAME).filter(
answer_id=answer_id).order_by('-create_date').values("hot_score").first()
if score:
return score
else:
return {}
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {}
def get_answer_show_by_index(self, answer_id):
try:
from talos.models.tractate.tractate import StrategyContentExposureIndex
......@@ -1038,10 +1078,13 @@ class Answer(models.Model):
n_days = today - delta
data = StrategyContentExposureIndex.objects.using(settings.DORIS_DB_NAME).filter(
create_day=n_days, card_id=answer_id, card_content_type="answer").first()
if data:
if data.ctr >= 0.05 and data.preciseexposure_num >= 50 and data.avg_page_stay >= 20:
return 0 # 0是正常展示 1不展示
return 1
else:
return 1
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return 1
......@@ -1053,7 +1096,7 @@ class Answer(models.Model):
delta_30 = datetime.timedelta(days=30)
delta_90 = datetime.timedelta(days=90)
delta_365 = datetime.timedelta(days=365)
if d2:
if d2 and create_time and (delta_30 or delta_90 or delta_365):
if d2 - delta_30 <= create_time:
return 30
elif d2 - delta_90 <= create_time:
......@@ -1068,6 +1111,19 @@ class Answer(models.Model):
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return 1000
def get_answer_tag(self, tag_list):
try:
association_tags_id_list = list()
tag_list = TagService._get_by_ids_from_cache_type(tag_list)
for item in tag_list:
association_tags_id_list.append(
{"id": item.id, "tag_name": item.name, "recommend_type": item.recommend_type,
"tag_type": item.tag_type})
return association_tags_id_list
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return []
class SendAnswer(models.Model):
class Meta:
......@@ -1677,6 +1733,15 @@ class StrategyAnswerSmrScore(models.Model):
create_date = models.BigIntegerField(max_length=50, verbose_name="时间")
class SrategyAnswerSmrScore(models.Model):
class Meta:
db_table = 'strategy_answer_smr_score'
answer_id = models.IntegerField(unique=True)
smart_rank_score = models.FloatField(verbose_name=u'新的smr_score', blank=True, default=0)
create_date = models.BigIntegerField(max_length=50, verbose_name="时间")
class SearchStrategyAnswerSmrScore(models.Model):
class Meta:
db_table = 'search_strategy_answer_new_smart_rank_score'
......@@ -1686,3 +1751,22 @@ class SearchStrategyAnswerSmrScore(models.Model):
create_date = models.BigIntegerField(max_length=50, verbose_name="时间")
new_goodclick = models.FloatField(verbose_name=u'新的点击分', blank=True, default=0)
smart_rank_v2 = models.FloatField(verbose_name=u'新的smr_score', blank=True, default=0)
class CommunitysStrategyAnswerSmrScore(models.Model):
class Meta:
db_table = 'communitys_strategy_answer_smr_score'
answer_id = models.IntegerField(unique=True)
smart_rank_score = models.FloatField(verbose_name=u'新的smr_score', blank=True, default=0)
create_date = models.BigIntegerField(max_length=50, verbose_name="时间")
good_click = models.FloatField(verbose_name=u'热度', blank=True, default=0)
class CommunitysStrategyAnswerHotScore(models.Model):
class Meta:
db_table = 'communitys_strategy_answer_hot_score'
answer_id = models.IntegerField(unique=True)
create_date = models.BigIntegerField(max_length=50, verbose_name="时间")
hot_score = models.FloatField(verbose_name=u'热度', blank=True, default=0)
......@@ -42,6 +42,6 @@ git+ssh://git@git.wanmeizhensuo.com/system/gm-tracer.git@v0.1.3
git+ssh://git@git.wanmeizhensuo.com/backend/helios.git@v0.7.5
git+ssh://git@git.wanmeizhensuo.com/backend/gm-logging.git@v0.8.5
git+ssh://git@git.wanmeizhensuo.com/backend/gm-rpcd.git@v0.2.5
git+ssh://git@git.wanmeizhensuo.com/rank/gm-text-miner.git@master
sqlalchemy==1.3.20
six==1.15.0
......@@ -205,6 +205,7 @@ class Tractate(models.Model):
delta_30 = datetime.timedelta(days=30)
delta_90 = datetime.timedelta(days=90)
delta_365 = datetime.timedelta(days=365)
if d2 and create_time and (delta_30 or delta_90 or delta_365):
if d2 - delta_30 <= create_time:
return 30
elif d2 - delta_90 <= create_time:
......@@ -213,6 +214,8 @@ class Tractate(models.Model):
return 365
else:
return 1000
else:
return 1000
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return 1000
......@@ -308,7 +311,6 @@ class Tractate(models.Model):
# 获取贴子标签和名称
def get_tag(self, tag_list):
try:
association_tags_id_list = list()
tag_list = TagService._get_by_ids_from_cache_type(tag_list)
......@@ -316,31 +318,24 @@ class Tractate(models.Model):
association_tags_id_list.append(
{"id": item.id, "tag_name": item.name, "recommend_type": item.recommend_type,
"tag_type": item.tag_type})
return association_tags_id_list
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return []
def get_tag_names(self, tag_list):
try:
association_tags_id_list = list()
tag_list = TagService._get_by_ids_from_cache_type(tag_list)
for item in tag_list:
if int(item.recommend_type) != 5 or int(item.tag_type) != 11:
association_tags_id_list.append(item.name)
return association_tags_id_list
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return []
def get_fresh_tag_names(self, new_tag_ids):
try:
from talos.services import AgileTagService
tag_name_list = list()
......@@ -348,7 +343,6 @@ class Tractate(models.Model):
for item in new_tag_ids:
data = agile_tag_info_dic.get(item, None)
tag_name_list.append(data.name)
return tag_name_list
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
......@@ -356,17 +350,12 @@ class Tractate(models.Model):
def get_tag_names_content(self, tag_list):
try:
association_tags_id_list = list()
tag_list = TagService._get_by_ids_from_cache_type(tag_list)
for item in tag_list:
if int(item.recommend_type) == 5 and int(item.tag_type) == 11:
association_tags_id_list.append(item.name)
return association_tags_id_list
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return []
......@@ -388,7 +377,6 @@ class Tractate(models.Model):
create_time__lte=now, is_deleted=False).count()
return int(vote_num) + 3 * int(reply_num) + 5 * int(click_num)
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return 0
......@@ -411,9 +399,7 @@ class Tractate(models.Model):
try:
result = TractateReply.objects.filter(tractate_id=self.id).values_list("create_time", flat=True).order_by(
"-create_time").first()
return result
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return ''
......@@ -424,9 +410,7 @@ class Tractate(models.Model):
result = UserConvertService.get_user_info_by_user_id(self.user_id)
if result.get("doctor_id") and result.get("doctor_type") == DOCTOR_TYPE.OFFICER:
is_office = 1
return is_office
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return 0
......@@ -482,8 +466,7 @@ class Tractate(models.Model):
n_days = today - delta
date_change = str(n_days).replace("-", "")
score = StrategyTractateSmrScoreV2.objects.using(settings.DORIS_DB_NAME).filter(
tractate_id=tractate_id).order_by('-create_date').values_list("smart_rank_score",
flat=True).first()
tractate_id=tractate_id).order_by('-create_date').values_list("smart_rank_score", flat=True).first()
if score:
return score
else:
......@@ -492,6 +475,14 @@ class Tractate(models.Model):
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return 0
def get_tractate_newuser_smr(self, tractate_id):
score = SrategyTractateSmrScore.objects.using(settings.DORIS_DB_NAME).filter(
tractate_id=tractate_id).order_by('-create_date').values_list("smart_rank_score", flat=True).first()
if score:
return score
else:
return 0
def get_search_tractate_new_smart_rank_score(self, tractate_id):
try:
today = datetime.datetime.now().date()
......@@ -524,6 +515,15 @@ class Tractate(models.Model):
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return 1
def get_tractate_tagv4_names(self, tractate_id):
try:
data = TractateTagV4.objects.using(settings.HERA_READ_DB).filter(tractate_id=tractate_id).values_list(
"tag_v4_id", flat=True)
return data
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return []
class TractateExtra(models.Model):
"""
......@@ -716,6 +716,7 @@ class StrategyTractateSmrScore(models.Model):
smart_rank_score = models.FloatField(verbose_name=u'新的smr_score', blank=True, default=0)
create_date = models.BigIntegerField(max_length=50, verbose_name="时间")
class StrategyTractateSmrScoreV2(models.Model):
class Meta:
db_table = 'search_strategy_tractate_new_smart_rank_score_v2'
......@@ -725,6 +726,15 @@ class StrategyTractateSmrScoreV2(models.Model):
create_date = models.BigIntegerField(max_length=50, verbose_name="时间")
class SrategyTractateSmrScore(models.Model):
class Meta:
db_table = 'strategy_tractate_smr_score'
tractate_id = models.IntegerField(unique=True)
smart_rank_score = models.FloatField(verbose_name=u'新的smr_score', blank=True, default=0)
create_date = models.BigIntegerField(max_length=50, verbose_name="时间")
class SearchStrategyTractateSmrScore(models.Model):
class Meta:
db_table = 'search_strategy_tractate_new_smart_rank_score'
......
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