Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
ffm-baseline
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ML
ffm-baseline
Commits
31183d0a
Commit
31183d0a
authored
Jun 04, 2020
by
任婷婷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
b3cf9c5e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
9 deletions
+19
-9
tool.py
eda/smart_rank/tool.py
+19
-9
No files found.
eda/smart_rank/tool.py
View file @
31183d0a
...
@@ -18,6 +18,8 @@ import pandas as pd
...
@@ -18,6 +18,8 @@ import pandas as pd
import
traceback
import
traceback
score_type_map
=
{
'henqiang'
:
15
,
'jiaoqiang'
:
12
,
'validate'
:
10
,
'ruoyixiang'
:
5
,
'ai_scan'
:
2
}
def
send_email
(
app
,
id
,
e
):
def
send_email
(
app
,
id
,
e
):
# 第三方 SMTP 服务
# 第三方 SMTP 服务
mail_host
=
'smtp.exmail.qq.com'
# 设置服务器
mail_host
=
'smtp.exmail.qq.com'
# 设置服务器
...
@@ -455,7 +457,7 @@ def connect_mysql():
...
@@ -455,7 +457,7 @@ def connect_mysql():
def
get_user_portrait_log
(
cl_id
):
def
get_user_portrait_log
(
cl_id
):
# try:
# try:
sql
=
"""select cl_id,event_cn, first_solutions, second_solutions, first_demands,
sql
=
"""select cl_id,event_cn, first_solutions, second_solutions, first_demands,
second_demands, first_positions, second_positions, projects
second_demands, first_positions, second_positions, projects
, score_type
from kafka_tag3_log where cl_id = '{}' """
.
format
(
cl_id
)
from kafka_tag3_log where cl_id = '{}' """
.
format
(
cl_id
)
db
,
cursor
=
get_jerry_test
()
db
,
cursor
=
get_jerry_test
()
cursor
.
execute
(
sql
)
cursor
.
execute
(
sql
)
...
@@ -472,11 +474,11 @@ def user_portrait_action_statistic(cl_id):
...
@@ -472,11 +474,11 @@ def user_portrait_action_statistic(cl_id):
# try:
# try:
ud_dict
=
{}
ud_dict
=
{}
user_df
=
get_user_portrait_log
(
cl_id
)
user_df
=
get_user_portrait_log
(
cl_id
)
print
(
'-'
*
100
)
#
print('-'*100)
print
(
'cl_id'
,
cl_id
)
#
print('cl_id',cl_id)
print
(
'user_df'
)
#
print('user_df')
print
(
user_df
)
#
print(user_df)
print
(
'-'
*
100
)
#
print('-' * 100)
if
user_df
:
if
user_df
:
for
ud
in
user_df
:
for
ud
in
user_df
:
ud2_list
=
ud
[
2
]
.
split
(
","
)
ud2_list
=
ud
[
2
]
.
split
(
","
)
...
@@ -486,7 +488,7 @@ def user_portrait_action_statistic(cl_id):
...
@@ -486,7 +488,7 @@ def user_portrait_action_statistic(cl_id):
ud6_list
=
ud
[
6
]
.
split
(
","
)
ud6_list
=
ud
[
6
]
.
split
(
","
)
ud7_list
=
ud
[
7
]
.
split
(
","
)
ud7_list
=
ud
[
7
]
.
split
(
","
)
ud8_list
=
ud
[
8
]
.
split
(
","
)
ud8_list
=
ud
[
8
]
.
split
(
","
)
score
=
score_type_map
[
ud
[
9
]]
if
ud
[
0
]
in
ud_dict
.
keys
():
if
ud
[
0
]
in
ud_dict
.
keys
():
if
ud
[
1
]
in
ud_dict
[
ud
[
0
]]
.
keys
():
if
ud
[
1
]
in
ud_dict
[
ud
[
0
]]
.
keys
():
ud_dict
[
ud
[
0
]][
ud
[
1
]][
"first_solutions"
]
.
extend
(
ud2_list
)
ud_dict
[
ud
[
0
]][
ud
[
1
]][
"first_solutions"
]
.
extend
(
ud2_list
)
...
@@ -496,20 +498,28 @@ def user_portrait_action_statistic(cl_id):
...
@@ -496,20 +498,28 @@ def user_portrait_action_statistic(cl_id):
ud_dict
[
ud
[
0
]][
ud
[
1
]][
"first_positions"
]
.
extend
(
ud6_list
)
ud_dict
[
ud
[
0
]][
ud
[
1
]][
"first_positions"
]
.
extend
(
ud6_list
)
ud_dict
[
ud
[
0
]][
ud
[
1
]][
"second_positions"
]
.
extend
(
ud7_list
)
ud_dict
[
ud
[
0
]][
ud
[
1
]][
"second_positions"
]
.
extend
(
ud7_list
)
ud_dict
[
ud
[
0
]][
ud
[
1
]][
"projects"
]
.
extend
(
ud8_list
)
ud_dict
[
ud
[
0
]][
ud
[
1
]][
"projects"
]
.
extend
(
ud8_list
)
ud_dict
[
ud
[
0
]][
ud
[
1
]][
"score"
]
=
score_type_map
[
ud
[
9
]]
elif
ud2_list
or
ud3_list
or
ud4_list
or
ud5_list
or
ud6_list
or
ud7_list
or
ud8_list
:
elif
ud2_list
or
ud3_list
or
ud4_list
or
ud5_list
or
ud6_list
or
ud7_list
or
ud8_list
:
ud_dict
[
ud
[
0
]][
ud
[
1
]]
=
{}
ud_dict
[
ud
[
0
]][
ud
[
1
]]
=
{}
ud_dict
[
ud
[
0
]][
ud
[
1
]]
=
{
"first_solutions"
:
ud2_list
,
"second_solutions"
:
ud3_list
,
ud_dict
[
ud
[
0
]][
ud
[
1
]]
=
{
"first_solutions"
:
ud2_list
,
"second_solutions"
:
ud3_list
,
"first_demands"
:
ud4_list
,
"second_demands"
:
ud5_list
,
"first_demands"
:
ud4_list
,
"second_demands"
:
ud5_list
,
"first_positions"
:
ud6_list
,
"second_positions"
:
ud7_list
,
"first_positions"
:
ud6_list
,
"second_positions"
:
ud7_list
,
"projects"
:
ud8_list
}
"projects"
:
ud8_list
,
"score"
:
score_type_map
[
ud
[
9
]]
}
else
:
else
:
ud_dict
[
ud
[
0
]]
=
{}
ud_dict
[
ud
[
0
]]
=
{}
ud_dict
[
ud
[
0
]][
ud
[
1
]]
=
{
"first_solutions"
:
ud2_list
,
"second_solutions"
:
ud3_list
,
ud_dict
[
ud
[
0
]][
ud
[
1
]]
=
{
"first_solutions"
:
ud2_list
,
"second_solutions"
:
ud3_list
,
"first_demands"
:
ud4_list
,
"second_demands"
:
ud5_list
,
"first_demands"
:
ud4_list
,
"second_demands"
:
ud5_list
,
"first_positions"
:
ud6_list
,
"second_positions"
:
ud7_list
,
"first_positions"
:
ud6_list
,
"second_positions"
:
ud7_list
,
"projects"
:
ud8_list
}
"projects"
:
ud8_list
,
"score"
:
score_type_map
[
ud
[
9
]]}
print
(
'*'
*
100
)
print
(
ud_dict
)
sorted
(
ud_dict
.
items
(),
key
=
lambda
item
:
item
[
1
][
0
][
7
])
print
(
'1'
*
100
)
print
(
ud_dict
)
return
ud_dict
return
ud_dict
# except Exception as e:
# except Exception as e:
# print('user_portrait_action_statistic error')
# print('user_portrait_action_statistic error')
# print(e)
# print(e)
...
...
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