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
bed30670
Commit
bed30670
authored
Feb 19, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
59e9675f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
13 deletions
+18
-13
tag_transfer.py
trans2es/utils/tag_transfer.py
+18
-13
No files found.
trans2es/utils/tag_transfer.py
View file @
bed30670
...
...
@@ -8,13 +8,14 @@ import logging
import
traceback
from
libs.tools
import
tzlc
from
trans2es.models.topic
import
Topic
from
trans2es.models.tag
import
TopicTag
,
CommunityTagType
,
CommunityTagTypeRelation
from
trans2es.models.tag
import
TopicTag
,
CommunityTagType
,
CommunityTagTypeRelation
import
datetime
class
TagTransfer
(
object
):
@classmethod
def
get_tag_data
(
cls
,
instance
):
def
get_tag_data
(
cls
,
instance
):
try
:
res
=
dict
()
...
...
@@ -22,14 +23,14 @@ class TagTransfer(object):
tag_name_terms_list
=
list
()
for
i
in
range
(
len
(
instance
.
name
)):
for
j
in
range
(
i
,
len
(
instance
.
name
)
+
1
):
for
j
in
range
(
i
,
len
(
instance
.
name
)
+
1
):
name_term
=
instance
.
name
[
i
:
j
]
.
strip
()
if
name_term
:
tag_name_terms_list
.
append
(
name_term
)
res
[
"suggest"
]
=
{
"input"
:
tag_name_terms_list
,
"contexts"
:{
"input"
:
tag_name_terms_list
,
"contexts"
:
{
"is_online"
:
[
instance
.
is_online
],
"is_deleted"
:
[
instance
.
is_deleted
]
}
...
...
@@ -39,19 +40,24 @@ class TagTransfer(object):
res
[
"is_deleted"
]
=
instance
.
is_deleted
res
[
"near_new_topic_num"
]
=
0
if
instance
.
is_online
==
True
and
instance
.
is_deleted
==
False
:
if
instance
.
is_online
==
True
and
instance
.
is_deleted
==
False
:
topic_id_list
=
list
()
sql_result_list
=
TopicTag
.
objects
.
filter
(
tag_id
=
instance
.
id
)
.
values_list
(
"topic_id"
,
flat
=
True
)
sql_result_list
=
TopicTag
.
objects
.
filter
(
tag_id
=
instance
.
id
)
.
values_list
(
"topic_id"
,
flat
=
True
)
for
item_id
in
sql_result_list
:
topic_id_list
.
append
(
item_id
)
time_base_val
=
datetime
.
datetime
.
strftime
(
datetime
.
datetime
.
now
()
+
datetime
.
timedelta
(
-
7
),
"
%
Y-
%
m-
%
d"
)
topic_num
=
Topic
.
objects
.
filter
(
id__in
=
topic_id_list
,
create_time__gte
=
time_base_val
)
.
count
()
topic_nums
=
0
time_base_val
=
datetime
.
datetime
.
strftime
(
datetime
.
datetime
.
now
()
+
datetime
.
timedelta
(
-
7
),
"
%
Y-
%
m-
%
d"
)
for
i
in
range
(
0
,
len
(
topic_id_list
),
1000
):
topic_num
=
Topic
.
objects
.
filter
(
id__in
=
topic_id_list
[
i
:
i
+
1000
],
create_time__gte
=
time_base_val
)
.
count
()
topic_nums
+=
topic_num
res
[
"near_new_topic_num"
]
=
topic_num
res
[
"near_new_topic_num"
]
=
topic_num
s
tag_type_sql_list
=
CommunityTagTypeRelation
.
objects
.
filter
(
tag_id
=
instance
.
id
)
.
values_list
(
"tag_type_id"
,
flat
=
True
)
tag_type_sql_list
=
CommunityTagTypeRelation
.
objects
.
filter
(
tag_id
=
instance
.
id
)
.
values_list
(
"tag_type_id"
,
flat
=
True
)
tag_type_list
=
list
()
for
tag_type_id
in
tag_type_sql_list
:
tag_type_list
.
append
(
tag_type_id
)
...
...
@@ -61,4 +67,4 @@ class TagTransfer(object):
return
res
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
dict
()
\ No newline at end of file
return
dict
()
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