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

Merge branch 'hot_score' into 'master'

Hot score

See merge request !30
parents b6b5e3f6 3ff57bb7
......@@ -62,8 +62,11 @@ 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['platform'] = answer.platform
# 新标签
......
......@@ -1032,10 +1032,6 @@ class Answer(models.Model):
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()
......@@ -1047,6 +1043,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
......@@ -1725,3 +1745,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)
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