Commit 6f1dcb79 authored by 李小芳's avatar 李小芳

smr

parent b339fba5
......@@ -63,9 +63,11 @@ def get_answers(pks):
score = answer.get_search_new_smart_rank_score(answer_id=answer.id)
item['detail_smr'] = score.get('smart_rank_v2', 0)
community_score = answer.get_community_answer_hot_score(answer.id)
community_score = answer.get_community_answer_smr_score(answer.id)
item['search_new_smr'] = community_score.get("smart_rank_score", 0)
item['new_goodclicks'] = community_score.get('good_click', 0)
community_hot_score = answer.get_community_answer_hot_score(answer.id)
item['new_goodclicks'] = community_hot_score.get('hot_score', 0)
item['platform'] = answer.platform
......
......@@ -1043,10 +1043,22 @@ class Answer(models.Model):
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {}
def get_community_answer_hot_score(self, answer_id):
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", "good_click").first()
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:
......@@ -1743,3 +1755,12 @@ class CommunitysStrategyAnswerSmrScore(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="时间")
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)
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