Commit b339fba5 authored by 李小芳's avatar 李小芳

smr

parent b6b5e3f6
...@@ -61,9 +61,12 @@ def get_answers(pks): ...@@ -61,9 +61,12 @@ def get_answers(pks):
item["hot_score"] = answer.get_hot_score_answer() item["hot_score"] = answer.get_hot_score_answer()
item['new_smr'] = answer.get_new_smart_rank_score(answer_id=answer.id) 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) 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) item['detail_smr'] = score.get('smart_rank_v2', 0)
community_score = answer.get_community_answer_hot_score(answer.id)
item['search_new_smr'] = community_score.get("smart_rank_score", 0)
item['new_goodclicks'] = community_score.get('good_click', 0)
item['platform'] = answer.platform item['platform'] = answer.platform
# 新标签 # 新标签
......
...@@ -1032,10 +1032,6 @@ class Answer(models.Model): ...@@ -1032,10 +1032,6 @@ class Answer(models.Model):
def get_search_new_smart_rank_score(self, answer_id): def get_search_new_smart_rank_score(self, answer_id):
try: 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( score = SearchStrategyAnswerSmrScore.objects.using(settings.DORIS_DB_NAME).filter(
answer_id=answer_id).order_by('-create_date').values("smart_rank_score", "new_goodclick", answer_id=answer_id).order_by('-create_date').values("smart_rank_score", "new_goodclick",
"smart_rank_v2").first() "smart_rank_v2").first()
...@@ -1047,6 +1043,18 @@ class Answer(models.Model): ...@@ -1047,6 +1043,18 @@ class Answer(models.Model):
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {} return {}
def get_community_answer_hot_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", "good_click").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): def get_answer_show_by_index(self, answer_id):
try: try:
from talos.models.tractate.tractate import StrategyContentExposureIndex from talos.models.tractate.tractate import StrategyContentExposureIndex
...@@ -1725,3 +1733,13 @@ class SearchStrategyAnswerSmrScore(models.Model): ...@@ -1725,3 +1733,13 @@ class SearchStrategyAnswerSmrScore(models.Model):
create_date = models.BigIntegerField(max_length=50, verbose_name="时间") create_date = models.BigIntegerField(max_length=50, verbose_name="时间")
new_goodclick = models.FloatField(verbose_name=u'新的点击分', blank=True, default=0) 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) 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)
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