Commit d627a6e9 authored by 段英荣's avatar 段英荣

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

parents ba594583 77250083
This diff is collapsed.
...@@ -747,6 +747,18 @@ class TopicUtils(object): ...@@ -747,6 +747,18 @@ class TopicUtils(object):
"order": "desc" "order": "desc"
}, },
}) })
elif sort_by == TOPIC_SEARCH_SORT.VOTE_NUM_AEC:
sort_rule.append({
"total_vote_num": {
"order": "asc"
},
})
elif sort_by == TOPIC_SEARCH_SORT.VOTE_NUM_DESC:
sort_rule.append({
"total_vote_num": {
"order": "desc"
},
})
return sort_rule return sort_rule
......
...@@ -92,8 +92,6 @@ def pictorial_topic(topic_id=-1, offset=0, size=10): ...@@ -92,8 +92,6 @@ def pictorial_topic(topic_id=-1, offset=0, size=10):
:return: :return:
""" """
try: try:
if not isinstance(topic_id, int):
user_id = -1
# 获取es链接对象 # 获取es链接对象
es_cli_obj = ESPerform.get_cli() es_cli_obj = ESPerform.get_cli()
...@@ -167,7 +165,7 @@ def pictorial_topic(topic_id=-1, offset=0, size=10): ...@@ -167,7 +165,7 @@ def pictorial_topic(topic_id=-1, offset=0, size=10):
"term": { "term": {
"is_online": True "is_online": True
} }
},{ }, {
"term": { "term": {
"is_deleted": False "is_deleted": False
} }
...@@ -202,3 +200,44 @@ def pictorial_topic(topic_id=-1, offset=0, size=10): ...@@ -202,3 +200,44 @@ def pictorial_topic(topic_id=-1, offset=0, size=10):
except: except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {"pictorial_ids_list": []} return {"pictorial_ids_list": []}
@bind("physical/search/pictorial_topic_sort")
def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10):
"""
:remark 小组排序,缺少:前1天发评论人数*x
:param user_id:
:param sort_type:
:param offset:
:param size:
:return:
"""
try:
if not isinstance(pictorial_id, int):
user_id = -1
q = {
"query":{
"term":{
"pictorial_id": pictorial_id}
},
"sort":{
"vote_num":{"order":"desc"}
}
}
pict_pictorial_ids_list =[]
# 获取es链接对象
es_cli_obj = ESPerform.get_cli()
result_dict = ESPerform.get_search_results(es_cli_obj, "topic", q, offset, size)
logging.info("get pictorial_topic_sort res:%s"%result_dict)
for item in result_dict["hits"]:
topic_id = item["_source"]["id"]
pict_pictorial_ids_list.append(topic_id)
return {"pict_pictorial_ids_list":pict_pictorial_ids_list}
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {"pict_pictorial_ids_list": []}
...@@ -5,12 +5,14 @@ ...@@ -5,12 +5,14 @@
"is_online":{"type":"boolean"},//上线 "is_online":{"type":"boolean"},//上线
"is_deleted":{"type":"boolean"}, "is_deleted":{"type":"boolean"},
"vote_num":{"type":"long"}, "vote_num":{"type":"long"},
"total_vote_num":{"type":"long"},
"reply_num":{"type":"long"}, "reply_num":{"type":"long"},
"name":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"}, "name":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},
"description":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"}, "description":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},
"content":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"}, "content":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},
"content_level":{"type":"text"}, "content_level":{"type":"text"},
"user_id":{"type":"long"}, "user_id":{"type":"long"},
"user_nick_name":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},//帖子用户名
"group_id":{"type":"long"}, //所在组ID "group_id":{"type":"long"}, //所在组ID
"tag_list":{"type":"long"},//标签属性 "tag_list":{"type":"long"},//标签属性
"edit_tag_list":{"type":"long"},//编辑标签 "edit_tag_list":{"type":"long"},//编辑标签
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"is_online":{"type":"boolean"},//上线 "is_online":{"type":"boolean"},//上线
"is_deleted":{"type":"boolean"}, "is_deleted":{"type":"boolean"},
"vote_num":{"type":"long"}, "vote_num":{"type":"long"},
"total_vote_num":{"type":"long"},
"reply_num":{"type":"long"}, "reply_num":{"type":"long"},
"name":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"}, "name":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},
"description":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"}, "description":{"type":"text","analyzer":"gm_default_index","search_analyzer":"gm_default_index"},
......
...@@ -82,6 +82,14 @@ class Topic(models.Model): ...@@ -82,6 +82,14 @@ class Topic(models.Model):
platform = models.IntegerField(verbose_name=u'平台来源', choices=GRAP_PLATFORM, default=GRAP_PLATFORM.ALPHA) platform = models.IntegerField(verbose_name=u'平台来源', choices=GRAP_PLATFORM, default=GRAP_PLATFORM.ALPHA)
platform_id = models.BigIntegerField(verbose_name='用平台ID', null=True) platform_id = models.BigIntegerField(verbose_name='用平台ID', null=True)
def get_virtual_vote_num(self):
try:
topic_extra = TopicExtra.object.get(topic_id=self.id)
return topic_extra.virtual_vote_num
except:
return 0
def get_pictorial_id(self): def get_pictorial_id(self):
try: try:
pictorial_id_list =[] pictorial_id_list =[]
...@@ -238,3 +246,16 @@ class PictorialTopic(models.Model): ...@@ -238,3 +246,16 @@ class PictorialTopic(models.Model):
is_online = models.BooleanField(verbose_name=u"是否有效", default=True) is_online = models.BooleanField(verbose_name=u"是否有效", default=True)
is_online = models.BooleanField(verbose_name=u'是否上线') is_online = models.BooleanField(verbose_name=u'是否上线')
is_deleted = models.BooleanField(verbose_name=u'是否删除') is_deleted = models.BooleanField(verbose_name=u'是否删除')
class TopicExtra(models.Model):
"""帖子相关额外信息"""
class Meta:
verbose_name = '帖子额外信息'
app_label = 'community'
db_table = 'topic_extra'
id = models.IntegerField(verbose_name=u'ID', primary_key=True)
topic_id = models.IntegerField(verbose_name=u"帖子ID",db_index=True)
virtual_vote_num = models.IntegerField(verbose_name="帖子虚拟点赞")
...@@ -109,6 +109,8 @@ class TopicTransfer(object): ...@@ -109,6 +109,8 @@ class TopicTransfer(object):
res["update_time"] = tzlc_update_time res["update_time"] = tzlc_update_time
res["update_time_val"] = int(time.mktime(tzlc_update_time.timetuple())) res["update_time_val"] = int(time.mktime(tzlc_update_time.timetuple()))
res["total_vote_num"] = instance.get_virtual_vote_num() + instance.vote_num
logging.info("test topic transfer time cost,time0:%d,time1:%d,time2:%d,time3:%d,time4:%d" % (time0,time1,time2,time3,time4)) logging.info("test topic transfer time cost,time0:%d,time1:%d,time2:%d,time3:%d,time4:%d" % (time0,time1,time2,time3,time4))
return res return res
except: except:
......
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