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

Merge branch 'similar_sort' into 'master'

modify topic_transfer

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