Commit f90de1e8 authored by lixiaofang's avatar lixiaofang

Merge branch 'test' of git.wanmeizhensuo.com:alpha/physical into test

parents 3b7f1317 8fc00b85
......@@ -182,6 +182,14 @@ class TopicUtils(object):
}
},
"weight": 1000
},
{
"filter": {
"term": {
"is_excellent": 1
}
},
"weight": 500
}
]
......@@ -219,7 +227,7 @@ class TopicUtils(object):
{
"filter": {"bool": {
"should": {"terms": {"tag_list": topic_tag_list}}}},
"weight": 10000
"weight": 2000
}
)
......@@ -228,7 +236,7 @@ class TopicUtils(object):
{
"filter": {"bool": {
"should": {"term": {"user_id": topic_user_id}}}},
"weight": 5000
"weight": 1500
}
)
query_function_score = {
......@@ -312,8 +320,9 @@ class TopicUtils(object):
q["collapse"] = {
"field": "user_id"
}
# "includes": ["id", "pictorial_id", "offline_score", "user_id", "edit_tag_list"]
q["_source"] = {
"includes": ["id", "pictorial_id", "offline_score", "user_id", "edit_tag_list"]
"includes": ["id"]
}
q["sort"] = [
# {
......
......@@ -160,7 +160,7 @@ def identity_tag_name(topic_content):
body = {
'text': topic_content,
'analyzer': "gm_default_search"
'analyzer': "gm_default_index"
}
cli_info = settings.TAG_ES_INFO_LIST
......
......@@ -43,6 +43,20 @@ class TopicImage(models.Model):
create_time = models.DateTimeField(verbose_name=u'创建时间', default=datetime.datetime.fromtimestamp(0))
update_time = models.DateTimeField(verbose_name=u'更新时间', default=datetime.datetime.fromtimestamp(0))
class ExcellentTopic(models.Model):
"""优质帖子"""
class Meta:
verbose_name = "优质帖子"
db_table = "excellent_topic"
id = models.IntegerField(verbose_name=u'ID', primary_key=True)
topic_id = models.IntegerField(verbose_name=u"帖子ID",db_index=True)
is_online = models.BooleanField(verbose_name=u'是否上线')
is_deleted = models.BooleanField(verbose_name=u'是否删除')
excellent_type = models.IntegerField(verbose_name=u"优质类型",db_index=True)
create_time = models.DateTimeField(verbose_name=u'创建时间', default=datetime.datetime.fromtimestamp(0))
update_time = models.DateTimeField(verbose_name=u'更新时间', default=datetime.datetime.fromtimestamp(0))
class Topic(models.Model):
class Meta:
......@@ -175,6 +189,17 @@ class Topic(models.Model):
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return []
def judge_if_excellent_topic(self, topic_id):
try:
excelllect_object = ExcellentTopic.objects.filter(topic_id=topic_id).first()
if excelllect_object and excelllect_object.is_online and not excelllect_object.is_deleted:
return True
else:
return False
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return False
def get_topic_offline_score(self):
try:
offline_score = 0.0
......@@ -198,8 +223,14 @@ class Topic(models.Model):
elif self.content_level == '4':
offline_score += 5.0
elif self.content_level == '6':
offline_score += 100.0
offline_score += 400.0
is_excellent = self.judge_if_excellent_topic(self.id)
if is_excellent:
offline_score += 200.0
if self.language_type == 1:
offline_score += 100.0
# exposure_count = ActionSumAboutTopic.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=self.id, data_type=1).count()
# click_count = ActionSumAboutTopic.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=self.id, data_type=2).count()
# uv_num = ActionSumAboutTopic.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=self.id, data_type=3).count()
......@@ -266,21 +297,6 @@ class TopicExtra(models.Model):
virtual_vote_num = models.IntegerField(verbose_name="帖子虚拟点赞")
class ExcellentTopic(models.Model):
"""优质帖子"""
class Meta:
verbose_name = "优质帖子"
db_table = "excellent_topic"
id = models.IntegerField(verbose_name=u'ID', primary_key=True)
topic_id = models.IntegerField(verbose_name=u"帖子ID",db_index=True)
is_online = models.BooleanField(verbose_name=u'是否上线')
is_deleted = models.BooleanField(verbose_name=u'是否删除')
excellent_type = models.IntegerField(verbose_name=u"优质类型",db_index=True)
create_time = models.DateTimeField(verbose_name=u'创建时间', default=datetime.datetime.fromtimestamp(0))
update_time = models.DateTimeField(verbose_name=u'更新时间', default=datetime.datetime.fromtimestamp(0))
class TopicHomeRecommend(models.Model):
"""运营位帖子"""
......
......@@ -115,8 +115,10 @@ class TopicTransfer(object):
if is_excellect:
res["is_excellent"] = 1
else:
excelllect_object = ExcellentTopic.objects.filter(topic_id=instance.id).first()
if excelllect_object and excelllect_object.is_online and not excelllect_object.is_deleted:
# excelllect_object = ExcellentTopic.objects.filter(topic_id=instance.id).first()
# if excelllect_object and excelllect_object.is_online and not excelllect_object.is_deleted:
is_excellent = instance.judge_if_excellent_topic(instance.id)
if is_excellent:
res["is_excellent"] = 1
else:
res["is_excellent"] = 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