Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
physical
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
physical
Commits
41dafa5e
Commit
41dafa5e
authored
Mar 09, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'similar_sort' into 'master'
modify topic_transfer See merge request
alpha/physical!146
parents
044bc51b
5e469c85
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
17 deletions
+37
-17
topic.py
trans2es/models/topic.py
+11
-6
topic_transfer.py
trans2es/utils/topic_transfer.py
+26
-11
No files found.
trans2es/models/topic.py
View file @
41dafa5e
...
...
@@ -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
:
...
...
trans2es/utils/topic_transfer.py
View file @
41dafa5e
...
...
@@ -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_ping_words
=
re
.
compile
(
u"[
\u3040
-
\u309f
]+"
)
m_ping
=
re_jp_ping_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)
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
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment