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
17a27d53
Commit
17a27d53
authored
Sep 06, 2019
by
高雅喆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
service_portrait into tidb
parent
9cce3629
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
+19
-4
dist_update_user_portrait_service.py
eda/smart_rank/dist_update_user_portrait_service.py
+19
-4
No files found.
eda/smart_rank/dist_update_user_portrait_service.py
View file @
17a27d53
...
...
@@ -210,14 +210,22 @@ def get_user_service_portrait(cl_id, all_word_tags, all_tag_tag_type, all_3tag_2
"where cl_id ='{}' and action not in "
\
"('api/order/validate','api/settlement/alipay_callback','do_search')"
.
format
(
cl_id
)
cur_jerry_test
.
execute
(
user_df_service_sql
)
user_df_service
=
pd
.
DataFrame
(
list
(
cur_jerry_test
.
fetchall
()))
user_df_service
.
columns
=
[
"time"
,
"cl_id"
,
"score_type"
,
"tag_id"
,
"tag_referrer"
,
"action"
]
data
=
list
(
cur_jerry_test
.
fetchall
())
if
data
:
user_df_service
=
pd
.
DataFrame
()
user_df_service
.
columns
=
[
"time"
,
"cl_id"
,
"score_type"
,
"tag_id"
,
"tag_referrer"
,
"action"
]
else
:
user_df_service
=
pd
.
DataFrame
(
columns
=
[
"time"
,
"cl_id"
,
"score_type"
,
"tag_id"
,
"tag_referrer"
,
"action"
])
# 用户的搜索行为
user_df_search_sql
=
"select time,cl_id,score_type,tag_id,tag_referrer,action from user_new_tag_log "
\
"where cl_id ='{}' and action = 'do_search'"
.
format
(
cl_id
)
cur_jerry_test
.
execute
(
user_df_search_sql
)
user_df_search
=
pd
.
DataFrame
(
list
(
cur_jerry_test
.
fetchall
()))
user_df_search
.
columns
=
[
"time"
,
"cl_id"
,
"score_type"
,
"tag_id"
,
"tag_referrer"
,
"action"
]
data_search
=
list
(
cur_jerry_test
.
fetchall
())
if
data_search
:
user_df_search
=
pd
.
DataFrame
()
user_df_search
.
columns
=
[
"time"
,
"cl_id"
,
"score_type"
,
"tag_id"
,
"tag_referrer"
,
"action"
]
else
:
user_df_search
=
pd
.
DataFrame
(
columns
=
[
"time"
,
"cl_id"
,
"score_type"
,
"tag_id"
,
"tag_referrer"
,
"action"
])
db_jerry_test
.
close
()
# 搜索词转成tag
...
...
@@ -255,6 +263,13 @@ def get_user_service_portrait(cl_id, all_word_tags, all_tag_tag_type, all_3tag_2
tag_id_list_json
=
json
.
dumps
(
gmkv_tag_score_sum
)
gm_kv_cli
.
set
(
cl_id_portrait_key
,
tag_id_list_json
)
gm_kv_cli
.
expire
(
cl_id_portrait_key
,
time
=
30
*
24
*
60
*
60
)
# 写tidb
stat_date
=
datetime
.
datetime
.
today
()
.
strftime
(
'
%
Y-
%
m-
%
d'
)
replace_sql
=
"""replace into user_service_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
=
gmkv_tag_score_sum
)
cur_jerry_test
.
execute
(
replace_sql
)
db_jerry_test
.
commit
()
db_jerry_test
.
close
()
return
gmkv_tag_score_sum
except
Exception
as
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