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
alpha
physical
Commits
8a99b4f1
Commit
8a99b4f1
authored
Mar 15, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
cdff4c1f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
tag_transfer.py
trans2es/utils/tag_transfer.py
+11
-4
user_transfer.py
trans2es/utils/user_transfer.py
+2
-1
No files found.
trans2es/utils/tag_transfer.py
View file @
8a99b4f1
...
@@ -10,6 +10,9 @@ from libs.tools import tzlc
...
@@ -10,6 +10,9 @@ from libs.tools import tzlc
from
trans2es.models.topic
import
Topic
from
trans2es.models.topic
import
Topic
from
trans2es.models.tag
import
TopicTag
,
CommunityTagType
,
CommunityTagTypeRelation
from
trans2es.models.tag
import
TopicTag
,
CommunityTagType
,
CommunityTagTypeRelation
import
datetime
import
datetime
from
django.conf
import
settings
class
TagTransfer
(
object
):
class
TagTransfer
(
object
):
...
@@ -38,20 +41,24 @@ class TagTransfer(object):
...
@@ -38,20 +41,24 @@ class TagTransfer(object):
res
[
"is_online"
]
=
instance
.
is_online
res
[
"is_online"
]
=
instance
.
is_online
res
[
"is_deleted"
]
=
instance
.
is_deleted
res
[
"is_deleted"
]
=
instance
.
is_deleted
res
[
"near_new_topic_num"
]
=
0
topic_num
=
0
res
[
"near_new_topic_num"
]
=
topic_num
if
instance
.
is_online
==
True
and
instance
.
is_deleted
==
False
:
if
instance
.
is_online
==
True
and
instance
.
is_deleted
==
False
:
topic_id_list
=
list
()
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
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
tag_id
=
instance
.
id
,
is_online
=
True
)
.
values_list
(
"topic_id"
,
flat
=
True
)
for
item_id
in
sql_result_list
:
for
item_id
in
sql_result_list
:
topic_id_list
.
append
(
item_id
)
topic_id_list
.
append
(
item_id
)
time_base_val
=
datetime
.
datetime
.
strftime
(
datetime
.
datetime
.
now
()
+
datetime
.
timedelta
(
-
7
),
"
%
Y-
%
m-
%
d"
)
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
()
for
topic_begin_index
in
range
(
0
,
len
(
topic_id_list
),
100
):
cur_topic_num
=
Topic
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
id__in
=
topic_id_list
[
topic_begin_index
:
topic_begin_index
+
100
],
create_time__gte
=
time_base_val
)
.
count
()
topic_num
+=
cur_topic_num
res
[
"near_new_topic_num"
]
=
topic_num
res
[
"near_new_topic_num"
]
=
topic_num
tag_type_sql_list
=
CommunityTagTypeRelation
.
objects
.
filter
(
tag_id
=
instance
.
id
)
.
values_list
(
"tag_type_id"
,
flat
=
True
)
tag_type_sql_list
=
CommunityTagTypeRelation
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
tag_id
=
instance
.
id
)
.
values_list
(
"tag_type_id"
,
flat
=
True
)
tag_type_list
=
list
()
tag_type_list
=
list
()
for
tag_type_id
in
tag_type_sql_list
:
for
tag_type_id
in
tag_type_sql_list
:
tag_type_list
.
append
(
tag_type_id
)
tag_type_list
.
append
(
tag_type_id
)
...
...
trans2es/utils/user_transfer.py
View file @
8a99b4f1
...
@@ -7,6 +7,7 @@ import traceback
...
@@ -7,6 +7,7 @@ import traceback
import
time
import
time
from
libs.tools
import
tzlc
from
libs.tools
import
tzlc
from
trans2es.models.user
import
User
from
trans2es.models.user
import
User
from
django.conf
import
settings
class
UserTransfer
(
object
):
class
UserTransfer
(
object
):
...
@@ -20,7 +21,7 @@ class UserTransfer(object):
...
@@ -20,7 +21,7 @@ class UserTransfer(object):
follow_user_detail_list
=
list
()
follow_user_detail_list
=
list
()
for
i
in
range
(
0
,
len
(
follow_user_id_list
),
1000
):
for
i
in
range
(
0
,
len
(
follow_user_id_list
),
1000
):
sql_data_list
=
User
.
objects
.
filter
(
user_id__in
=
follow_user_id_list
[
i
:
i
+
1000
],
is_online
=
True
,
sql_data_list
=
User
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id__in
=
follow_user_id_list
[
i
:
i
+
1000
],
is_online
=
True
,
is_deleted
=
False
)
is_deleted
=
False
)
for
detail_data
in
sql_data_list
:
for
detail_data
in
sql_data_list
:
item
=
{
item
=
{
...
...
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