Commit 41dafa5e authored by 段英荣's avatar 段英荣

Merge branch 'similar_sort' into 'master'

modify topic_transfer

See merge request alpha/physical!146
parents 044bc51b 5e469c85
......@@ -98,12 +98,17 @@ class Topic(models.Model):
topic_tag_id_list = list()
edit_tag_id_list = list()
query_results = TopicTag.objects.filter(topic_id=self.id)
for item in query_results:
is_collection = Tag.objects.filter(is_online=True,id=item.tag_id,collection=1)
if is_collection:
edit_tag_id_list.append(item.tag_id)
topic_tag_id_list.append(item.tag_id)
tag_id_list = TopicTag.objects.filter(topic_id=self.id).values_list("tag_id", flat=True)
tag_query_results = Tag.objects.filter(id__in=tag_id_list)
for tag_item in tag_query_results:
is_online=tag_item.is_online
is_deleted=tag_item.is_deleted
collection=tag_item.collection
if is_online and not is_deleted:
topic_tag_id_list.append(tag_item.tag_id)
if collection:
edit_tag_id_list.append(tag_item.tag_id)
return (topic_tag_id_list, edit_tag_id_list)
except:
......
......@@ -7,6 +7,7 @@ import traceback
from libs.tools import tzlc
import time
import re
import datetime
class TopicTransfer(object):
......@@ -35,28 +36,41 @@ class TopicTransfer(object):
res["pick_id_list"] = instance.get_pick_id_info()
begin = datetime.datetime.now()
(topic_tag_id_list, edit_tag_id_list) = instance.get_topic_tag_id_list()
res["tag_list"] = topic_tag_id_list
res["edit_tag_list"] = edit_tag_id_list
end = datetime.datetime.now()
time1 = (end-begin).seconds
begin = datetime.datetime.now()
res["tag_name_list"] = instance.get_tag_name_list(res["tag_list"])
end = datetime.datetime.now()
time2 = (end-begin).seconds
begin = datetime.datetime.now()
res["offline_score"] = instance.get_topic_offline_score()
end = datetime.datetime.now()
time3 = (end-begin).seconds
res["manual_score"] = instance.drop_score
res["has_image"] = instance.topic_has_image()
res["language_type"] = instance.language_type
# 片假名
re_jp_pian_words = re.compile(u"[\u30a0-\u30ff]+")
m_pian = re_jp_pian_words.search(instance.content, 0)
# # 片假名
# re_jp_pian_words = re.compile(u"[\u30a0-\u30ff]+")
# m_pian = re_jp_pian_words.search(instance.content, 0)
#
# # 平假名
# re_jp_ping_words = re.compile(u"[\u3040-\u309f]+")
# m_ping = re_jp_ping_words.search(instance.content, 0)
# 平假名
re_jp_ping_words = re.compile(u"[\u3040-\u309f]+")
m_ping = re_jp_ping_words.search(instance.content, 0)
if m_pian or m_ping:
res["language_type"] = 10
else:
res["language_type"] = instance.language_type
# if m_pian or m_ping:
# res["language_type"] = 10
# else:
# res["language_type"] = instance.language_type
create_time = instance.create_time
......@@ -70,6 +84,7 @@ class TopicTransfer(object):
res["update_time"] = tzlc_update_time
res["update_time_val"] = int(time.mktime(tzlc_update_time.timetuple()))
logging.info("test topic transfer time cost,time1:%d,time2:%d,time3:%d" % (time1,time2,time3))
return res
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
......
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