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
a91354de
Commit
a91354de
authored
Aug 20, 2019
by
高雅喆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
data 2 gmkv
parent
ac81bcc4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
dist_update_user_history_order_tags.py
eda/smart_rank/dist_update_user_history_order_tags.py
+7
-1
dist_update_user_portrait.py
eda/smart_rank/dist_update_user_portrait.py
+7
-1
No files found.
eda/smart_rank/dist_update_user_history_order_tags.py
View file @
a91354de
...
@@ -17,6 +17,7 @@ import numpy as np
...
@@ -17,6 +17,7 @@ import numpy as np
import
pandas
as
pd
import
pandas
as
pd
from
pyspark.sql.functions
import
lit
from
pyspark.sql.functions
import
lit
from
pyspark.sql.functions
import
concat_ws
from
pyspark.sql.functions
import
concat_ws
import
redis
def
send_email
(
app
,
id
,
e
):
def
send_email
(
app
,
id
,
e
):
...
@@ -66,7 +67,12 @@ def get_user_history_order_service_tag(user_id, stat_date):
...
@@ -66,7 +67,12 @@ def get_user_history_order_service_tag(user_id, stat_date):
cur_zhengxing
.
execute
(
sql
)
cur_zhengxing
.
execute
(
sql
)
tags_dict
=
cur_zhengxing
.
fetchall
()
tags_dict
=
cur_zhengxing
.
fetchall
()
tags_list
=
[
i
[
"tag_id"
]
for
i
in
tags_dict
]
tags_list
=
[
i
[
"tag_id"
]
for
i
in
tags_dict
]
# 写gmkv
gm_kv_cli
=
redis
.
Redis
(
host
=
"172.16.40.135"
,
port
=
5379
,
db
=
6
,
socket_timeout
=
2000
)
user_history_order_tags_key
=
"user:history_order:tags:user_id:"
+
str
(
user_id
)
tags_list_json
=
json
.
dumps
(
tags_list
)
gm_kv_cli
.
set
(
user_history_order_tags_key
,
tags_list_json
)
# 写tidb
sql_cl_id
=
"select device_id from statistic_device where id = (select max(device_id) from statistic_device_user where user_id =
%
d) "
%
(
int
(
user_id
))
sql_cl_id
=
"select device_id from statistic_device where id = (select max(device_id) from statistic_device_user where user_id =
%
d) "
%
(
int
(
user_id
))
cur_zhengxing
.
execute
(
sql_cl_id
)
cur_zhengxing
.
execute
(
sql_cl_id
)
cl_id
=
cur_zhengxing
.
fetchall
()[
0
][
"device_id"
]
cl_id
=
cur_zhengxing
.
fetchall
()[
0
][
"device_id"
]
...
...
eda/smart_rank/dist_update_user_portrait.py
View file @
a91354de
...
@@ -17,6 +17,7 @@ import numpy as np
...
@@ -17,6 +17,7 @@ import numpy as np
import
pandas
as
pd
import
pandas
as
pd
from
pyspark.sql.functions
import
lit
from
pyspark.sql.functions
import
lit
from
pyspark.sql.functions
import
concat_ws
from
pyspark.sql.functions
import
concat_ws
import
redis
def
send_email
(
app
,
id
,
e
):
def
send_email
(
app
,
id
,
e
):
...
@@ -109,7 +110,12 @@ def get_user_tag_score(cl_id, all_log_df, stat_date, size=10):
...
@@ -109,7 +110,12 @@ def get_user_tag_score(cl_id, all_log_df, stat_date, size=10):
finally_score
.
drop_duplicates
(
subset
=
"tag_id"
,
inplace
=
True
)
finally_score
.
drop_duplicates
(
subset
=
"tag_id"
,
inplace
=
True
)
finally_score_lst
=
finally_score
[[
"tag_id"
,
"tag_score"
]]
.
to_dict
(
'record'
)
finally_score_lst
=
finally_score
[[
"tag_id"
,
"tag_score"
]]
.
to_dict
(
'record'
)
tag_id_list
=
tag_list2dict
(
finally_score_lst
,
size
)
tag_id_list
=
tag_list2dict
(
finally_score_lst
,
size
)
# 写gmkv
gm_kv_cli
=
redis
.
Redis
(
host
=
"172.16.40.135"
,
port
=
5379
,
db
=
6
,
socket_timeout
=
2000
)
cl_id_portrait_key
=
"user:portrait_tags:cl_id:"
+
str
(
cl_id
)
tag_id_list_json
=
json
.
dumps
(
tag_id_list
)
gm_kv_cli
.
set
(
cl_id_portrait_key
,
tag_id_list_json
)
# 写tidb
replace_sql
=
"""replace into user_portrait_tags (stat_date, cl_id, tag_list) values("{stat_date}","{cl_id}","{tag_list}")"""
\
replace_sql
=
"""replace into user_portrait_tags (stat_date, cl_id, tag_list) values("{stat_date}","{cl_id}","{tag_list}")"""
\
.
format
(
stat_date
=
stat_date
,
cl_id
=
cl_id
,
tag_list
=
tag_id_list
)
.
format
(
stat_date
=
stat_date
,
cl_id
=
cl_id
,
tag_list
=
tag_id_list
)
cur_jerry_test
.
execute
(
replace_sql
)
cur_jerry_test
.
execute
(
replace_sql
)
...
...
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