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

smr

parent 70f3fb71
......@@ -200,8 +200,10 @@ def get_answers(pks):
projects = [list(item.keys())[0] for item in result_data.get("projects", [])]
item['portrait_tag_name'].extend(projects)
data.append(item)
if 3315 in item['operators_add_tags']:
item['new_smr'] = answer.get_answer_newuser_smr(answer_id=answer.id)
data.append(item)
except (Answer.DoesNotExist, Question.DoesNotExist):
pass
......
......@@ -232,13 +232,16 @@ def get_tractate(pks):
get_names=True)
# 首页精选增加内容分类和明星列表和网红列表
result_data =alo_model.run(tractate.content)
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)
if 3315 in item['operators_add_tags']:
item['new_smr'] = tractate.get_tractate_newuser_smr(tractate_id=tractate.id)
data.append(item)
logging.info("get data:%s" % data)
return data
......
......@@ -1013,6 +1013,14 @@ 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_search_new_smart_rank_score(self, answer_id):
try:
today = datetime.datetime.now().date()
......@@ -1677,6 +1685,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'
......
......@@ -482,8 +482,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 +491,14 @@ class Tractate(models.Model):
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return 0
def get_tratate_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()
......@@ -716,6 +723,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 +733,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