Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
meta_base_code
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
黎涛
meta_base_code
Commits
184cc208
Commit
184cc208
authored
Sep 14, 2020
by
litaolemo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
f912ba9e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
3 deletions
+46
-3
portary_article_distribution.py
task/portary_article_distribution.py
+46
-3
No files found.
task/portary_article_distribution.py
View file @
184cc208
...
@@ -40,6 +40,17 @@ def con_sql(sql):
...
@@ -40,6 +40,17 @@ def con_sql(sql):
return
result
return
result
second_demands_zero_dict
=
{
"answer"
:{},
"tractate"
:{},
"diary"
:{},
}
project_zero_dict
=
{
"answer"
:{},
"tractate"
:{},
"diary"
:{},
}
bulk_dict
=
{
bulk_dict
=
{
0
:
[
0
,
0
,
0
],
0
:
[
0
,
0
,
0
],
10
:
[
0
,
0
,
0
],
10
:
[
0
,
0
,
0
],
...
@@ -67,6 +78,21 @@ for redis_count,res in enumerate(user_portrait_scan):
...
@@ -67,6 +78,21 @@ for redis_count,res in enumerate(user_portrait_scan):
for
key
in
tag
:
for
key
in
tag
:
total_answer_content
,
total_tractate_content
,
total_diary_content
,
sum_num
=
\
total_answer_content
,
total_tractate_content
,
total_diary_content
,
sum_num
=
\
tag
[
key
]
tag
[
key
]
if
not
total_answer_content
:
if
second_demands_zero_dict
[
"answer"
]
.
get
(
key
):
second_demands_zero_dict
[
"answer"
][
key
]
+=
1
else
:
second_demands_zero_dict
[
"answer"
][
key
]
=
1
if
not
total_tractate_content
:
if
second_demands_zero_dict
[
"tractate"
]
.
get
(
key
):
second_demands_zero_dict
[
"tractate"
][
key
]
+=
1
else
:
second_demands_zero_dict
[
"tractate"
][
key
]
=
1
if
not
total_diary_content
:
if
second_demands_zero_dict
[
"diary"
]
.
get
(
key
):
second_demands_zero_dict
[
"diary"
][
key
]
+=
1
else
:
second_demands_zero_dict
[
"diary"
][
key
]
=
1
total_answer_content_num
+=
total_answer_content
total_answer_content_num
+=
total_answer_content
total_tractate_content_num
+=
total_tractate_content
total_tractate_content_num
+=
total_tractate_content
total_diary_content_num
+=
total_diary_content
total_diary_content_num
+=
total_diary_content
...
@@ -79,6 +105,21 @@ for redis_count,res in enumerate(user_portrait_scan):
...
@@ -79,6 +105,21 @@ for redis_count,res in enumerate(user_portrait_scan):
for
key
in
tag
:
for
key
in
tag
:
total_answer_content
,
total_tractate_content
,
total_diary_content
,
sum_num
=
\
total_answer_content
,
total_tractate_content
,
total_diary_content
,
sum_num
=
\
tag
[
key
]
tag
[
key
]
if
not
total_answer_content
:
if
project_zero_dict
[
"answer"
]
.
get
(
key
):
project_zero_dict
[
"answer"
][
key
]
+=
1
else
:
project_zero_dict
[
"answer"
][
key
]
=
1
if
not
total_tractate_content
:
if
project_zero_dict
[
"tractate"
]
.
get
(
key
):
project_zero_dict
[
"tractate"
][
key
]
+=
1
else
:
project_zero_dict
[
"tractate"
][
key
]
=
1
if
not
total_diary_content
:
if
project_zero_dict
[
"diary"
]
.
get
(
key
):
project_zero_dict
[
"diary"
][
key
]
+=
1
else
:
project_zero_dict
[
"diary"
][
key
]
=
1
total_answer_content_num
+=
total_answer_content
total_answer_content_num
+=
total_answer_content
total_tractate_content_num
+=
total_tractate_content
total_tractate_content_num
+=
total_tractate_content
total_diary_content_num
+=
total_diary_content
total_diary_content_num
+=
total_diary_content
...
@@ -131,7 +172,7 @@ for redis_count,res in enumerate(user_portrait_scan):
...
@@ -131,7 +172,7 @@ for redis_count,res in enumerate(user_portrait_scan):
bulk_dict
[
1000
][
2
]
+=
1
bulk_dict
[
1000
][
2
]
+=
1
# print(bulk_dict)
# print(bulk_dict)
if
redis_count
%
5000
==
0
:
if
redis_count
%
5000
0
==
0
:
print
(
redis_count
)
print
(
redis_count
)
for
page_type
in
range
(
3
):
for
page_type
in
range
(
3
):
if
page_type
==
0
:
if
page_type
==
0
:
...
@@ -156,6 +197,8 @@ for redis_count,res in enumerate(user_portrait_scan):
...
@@ -156,6 +197,8 @@ for redis_count,res in enumerate(user_portrait_scan):
res
=
cursor
.
execute
(
instert_sql
)
res
=
cursor
.
execute
(
instert_sql
)
db
.
commit
()
db
.
commit
()
# print(res)
# print(res)
print
(
second_demands_zero_dict
)
print
(
project_zero_dict
)
for
page_type
in
range
(
3
):
for
page_type
in
range
(
3
):
...
@@ -171,13 +214,13 @@ for page_type in range(3):
...
@@ -171,13 +214,13 @@ for page_type in range(3):
page_type,num_type,num_value,pid) VALUES('{page_type_str}','{num_type}',{num_value},'{pid}');"""
.
format
(
page_type,num_type,num_value,pid) VALUES('{page_type_str}','{num_type}',{num_value},'{pid}');"""
.
format
(
page_type_str
=
page_type_str
,
pid
=
pid
,
num_type
=
str
(
count_num
),
num_value
=
bulk_dict
[
count_num
][
page_type
]
page_type_str
=
page_type_str
,
pid
=
pid
,
num_type
=
str
(
count_num
),
num_value
=
bulk_dict
[
count_num
][
page_type
]
)
)
print
(
instert_sql
)
#
print(instert_sql)
# cursor.execute("set names 'UTF8'")
# cursor.execute("set names 'UTF8'")
db
=
pymysql
.
connect
(
host
=
'172.16.40.158'
,
port
=
4000
,
user
=
'st_user'
,
passwd
=
'aqpuBLYzEV7tML5RPsN1pntUzFy'
,
db
=
pymysql
.
connect
(
host
=
'172.16.40.158'
,
port
=
4000
,
user
=
'st_user'
,
passwd
=
'aqpuBLYzEV7tML5RPsN1pntUzFy'
,
db
=
'jerry_prod'
)
db
=
'jerry_prod'
)
cursor
=
db
.
cursor
()
cursor
=
db
.
cursor
()
res
=
cursor
.
execute
(
instert_sql
)
res
=
cursor
.
execute
(
instert_sql
)
db
.
commit
()
db
.
commit
()
print
(
res
)
#
print(res)
# cursor.executemany()
# cursor.executemany()
db
.
close
()
db
.
close
()
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