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
0795d15b
Commit
0795d15b
authored
Oct 18, 2019
by
谢祁峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
aff6859a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
83 deletions
+84
-83
collect_data.py
linucb/views/collect_data.py
+84
-83
No files found.
linucb/views/collect_data.py
View file @
0795d15b
...
@@ -565,93 +565,94 @@ class CollectData(object):
...
@@ -565,93 +565,94 @@ class CollectData(object):
logging
.
info
(
"skin_check topic type:
%
s, device_id:
%
s, tag_query_results:
%
s"
%
logging
.
info
(
"skin_check topic type:
%
s, device_id:
%
s, tag_query_results:
%
s"
%
(
str
(
data
[
'SYS'
][
'action'
]),
str
(
device_id
),
(
str
(
data
[
'SYS'
][
'action'
]),
str
(
device_id
),
str
(
tag_query_results_multi
)))
str
(
tag_query_results_multi
)))
# 品牌问卷进linucb
# 品牌问卷进linucb
elif
'SYS'
in
data
and
'APP'
in
data
and
'action'
in
data
[
'SYS'
]
and
data
[
'SYS'
][
elif
'SYS'
in
data
and
'APP'
in
data
and
'action'
in
data
[
'SYS'
]
and
data
[
'SYS'
][
'action'
]
==
"venus/community/survey_question/submit"
:
'action'
]
==
"venus/community/survey_question/submit"
:
device_id
=
data
[
'SYS'
][
'cl_id'
]
device_id
=
data
[
'SYS'
][
'cl_id'
]
tagid_list
=
list
(
data
[
'APP'
]
.
get
(
'answer_tag'
,
[]))
tagid_list
=
list
(
data
[
'APP'
]
.
get
(
'answer_tag'
,
[]))
user_id
=
data
[
'SYS'
]
.
get
(
'user_id'
,
None
)
user_id
=
data
[
'SYS'
]
.
get
(
'user_id'
,
None
)
logging
.
info
(
"survey_question type:
%
s, device_id:
%
s, answer_tag:
%
s"
%
logging
.
info
(
"survey_question type:
%
s, device_id:
%
s, answer_tag:
%
s"
%
(
str
(
data
[
'SYS'
][
'action'
]),
str
(
device_id
),
str
(
tagid_list
)))
(
str
(
data
[
'SYS'
][
'action'
]),
str
(
device_id
),
str
(
tagid_list
)))
if
len
(
tagid_list
)
>
0
:
if
len
(
tagid_list
)
>
0
:
tag_query_results
=
list
(
Tag
.
objects
.
using
(
settings
.
SLAVE1_DB_NAME
)
.
filter
(
tag_query_results
=
list
(
Tag
.
objects
.
using
(
settings
.
SLAVE1_DB_NAME
)
.
filter
(
id__in
=
tagid_list
,
is_online
=
True
,
is_deleted
=
False
,
id__in
=
tagid_list
,
is_online
=
True
,
is_deleted
=
False
,
is_category
=
False
)
.
values_list
(
"id"
,
flat
=
True
))
is_category
=
False
)
.
values_list
(
"id"
,
flat
=
True
))
tag_query_results_multi
=
[
i
for
i
in
tagid_list
if
i
in
tag_query_results
]
tag_query_results_multi
=
[
i
for
i
in
tagid_list
if
i
in
tag_query_results
]
is_click
=
1
is_click
=
1
is_vote
=
0
is_vote
=
0
reward
=
1
if
is_click
or
is_vote
else
0
reward
=
1
if
is_click
or
is_vote
else
0
# 移植老用户的lin信息到ctr特征策略
# 移植老用户的lin信息到ctr特征策略
self
.
transfer_old_info2ctr_feature_key
(
device_id
)
self
.
transfer_old_info2ctr_feature_key
(
device_id
)
for
i
in
range
(
5
):
for
i
in
range
(
5
):
for
tag_id
in
tag_query_results_multi
:
for
tag_id
in
tag_query_results_multi
:
self
.
update_user_linucb_tag_info
(
reward
,
device_id
,
tag_id
,
self
.
update_user_linucb_tag_info
(
reward
,
device_id
,
tag_id
,
user_feature
,
user_feature
,
self
.
linucb_matrix_redis_prefix
)
self
.
linucb_matrix_redis_prefix
)
# 获取tag的ctr信息
# 获取tag的ctr信息
device_tag_ctr
=
self
.
get_device_tag_ctr
(
device_id
,
tag_id
)
device_tag_ctr
=
self
.
get_device_tag_ctr
(
device_id
,
tag_id
)
user_feature_ctr
=
[
device_tag_ctr
,
device_tag_ctr
]
user_feature_ctr
=
[
device_tag_ctr
,
device_tag_ctr
]
self
.
update_user_linucb_tag_info
(
reward
,
device_id
,
tag_id
,
self
.
update_user_linucb_tag_info
(
reward
,
device_id
,
tag_id
,
user_feature_ctr
,
user_feature_ctr
,
self
.
ctr_linucb_matrix_redis_prefix
)
self
.
ctr_linucb_matrix_redis_prefix
)
# 更新该用户的推荐tag数据,放在 更新完成user tag行为信息之后
# 更新该用户的推荐tag数据,放在 更新完成user tag行为信息之后
self
.
update_recommend_tag_list
(
device_id
,
user_feature
,
user_id
,
self
.
update_recommend_tag_list
(
device_id
,
user_feature
,
user_id
,
linucb_matrix_prefix
=
self
.
linucb_matrix_redis_prefix
,
linucb_matrix_prefix
=
self
.
linucb_matrix_redis_prefix
,
linucb_recommend_tag_prefix
=
self
.
linucb_recommend_redis_prefix
,
linucb_recommend_tag_prefix
=
self
.
linucb_recommend_redis_prefix
,
linucb_topic_ids_prefix
=
self
.
linucb_recommend_topic_id_prefix
,
linucb_topic_ids_prefix
=
self
.
linucb_recommend_topic_id_prefix
,
linucb_pictorial_ids_prefix
=
self
.
linucb_recommend_pictorial_id_prefix
)
linucb_pictorial_ids_prefix
=
self
.
linucb_recommend_pictorial_id_prefix
)
self
.
update_recommend_tag_list
(
device_id
,
user_feature
,
user_id
,
self
.
update_recommend_tag_list
(
device_id
,
user_feature
,
user_id
,
linucb_matrix_prefix
=
self
.
ctr_linucb_matrix_redis_prefix
,
linucb_matrix_prefix
=
self
.
ctr_linucb_matrix_redis_prefix
,
linucb_recommend_tag_prefix
=
self
.
ctr_linucb_recommend_redis_prefix
,
linucb_recommend_tag_prefix
=
self
.
ctr_linucb_recommend_redis_prefix
,
linucb_topic_ids_prefix
=
self
.
ctr_linucb_recommend_topic_id_prefix
,
linucb_topic_ids_prefix
=
self
.
ctr_linucb_recommend_topic_id_prefix
,
linucb_pictorial_ids_prefix
=
self
.
ctr_linucb_recommend_pictorial_id_prefix
)
linucb_pictorial_ids_prefix
=
self
.
ctr_linucb_recommend_pictorial_id_prefix
)
logging
.
info
(
"survey_question type:
%
s, device_id:
%
s, tagid_list:
%
s"
%
logging
.
info
(
"survey_question type:
%
s, device_id:
%
s, tagid_list:
%
s"
%
(
str
(
data
[
'SYS'
][
'action'
]),
str
(
device_id
),
(
str
(
data
[
'SYS'
][
'action'
]),
str
(
device_id
),
str
(
tag_query_results_multi
)))
str
(
tag_query_results_multi
)))
# 首页搜索精准匹配标签关键字进linucb
# 首页搜索精准匹配标签关键字进linucb
elif
'SYS'
in
data
and
'APP'
in
data
and
'action'
in
data
[
'SYS'
]
and
"api/v1/cards/topic"
in
\
elif
'SYS'
in
data
and
'APP'
in
data
and
'action'
in
data
[
data
[
'SYS'
][
'SYS'
]
and
"api/v1/cards/topic"
in
\
'action'
]:
data
[
'SYS'
][
tag_name
=
raw_val_dict
[
"APP"
]
.
get
(
"query"
,
""
)
'action'
]:
tag_id
=
raw_val_dict
[
"APP"
]
.
get
(
"action"
)
tag_name
=
raw_val_dict
[
"APP"
]
.
get
(
"query"
,
""
)
tag_list
=
list
(
Tag
.
objects
.
using
(
settings
.
SLAVE1_DB_NAME
)
.
filter
(
tag_id
=
raw_val_dict
[
"APP"
]
.
get
(
"action"
)
tag
=
tag_name
)
.
values_list
(
"id"
))
tag_list
=
list
(
Tag
.
objects
.
using
(
settings
.
SLAVE1_DB_NAME
)
.
filter
(
tag_list
.
append
(
tag_id
)
tag
=
tag_name
)
.
values_list
(
"id"
))
logging
.
info
(
"action=home_page_search,tagid_list:
%
s"
%
tag_list
)
tag_list
.
append
(
tag_id
)
device_id
=
raw_val_dict
[
"device"
][
"device_id"
]
logging
.
info
(
"action=home_page_search,tagid_list:
%
s"
%
tag_list
)
user_id
=
raw_val_dict
[
"user_id"
]
if
"user_id"
in
raw_val_dict
else
None
device_id
=
raw_val_dict
[
"device"
][
"device_id"
]
self
.
transfer_update_recommend_tag_list
(
device_id
,
user_feature
,
user_id
,
tag_list
,
user_id
=
raw_val_dict
[
"user_id"
]
if
"user_id"
in
raw_val_dict
else
None
5
)
self
.
transfer_update_recommend_tag_list
(
device_id
,
user_feature
,
user_id
,
tag_list
,
logging
.
info
(
"action=home_page_search,update lintag success"
)
5
)
# (客户端创建回答,后台创建回答或修改回答关联标签关键字进linucb
logging
.
info
(
"action=home_page_search,update lintag success"
)
elif
'SYS'
in
data
and
'APP'
in
data
and
'action'
in
data
[
'SYS'
]
and
\
# (客户端创建回答,后台创建回答或修改回答关联标签关键字进linucb
(
"venus/community/topic/create"
in
data
[
'SYS'
][
elif
'SYS'
in
data
and
'APP'
in
data
and
'action'
in
data
[
'SYS'
]
and
\
'action'
]
or
"venus/sun/topic/edit"
in
data
[
'SYS'
][
'action'
]):
(
"venus/community/topic/create"
in
data
[
'SYS'
][
tag_ids
=
list
(
raw_val_dict
[
"APP"
]
.
get
(
"tag_ids"
,
[]))
'action'
]
or
"venus/sun/topic/edit"
in
data
[
'SYS'
][
'action'
]):
tag_list
=
list
(
Tag
.
objects
.
using
(
settings
.
SLAVE1_DB_NAME
)
.
filter
(
tag_ids
=
list
(
raw_val_dict
[
"APP"
]
.
get
(
"tag_ids"
,
[]))
id__in
=
tag_ids
,
is_online
=
True
,
is_deleted
=
False
,
tag_list
=
list
(
Tag
.
objects
.
using
(
settings
.
SLAVE1_DB_NAME
)
.
filter
(
is_category
=
False
)
.
values_list
(
"id"
))
id__in
=
tag_ids
,
is_online
=
True
,
is_deleted
=
False
,
device_id
=
raw_val_dict
[
"device"
][
"device_id"
]
is_category
=
False
)
.
values_list
(
"id"
))
user_id
=
raw_val_dict
[
"user_id"
]
if
"user_id"
in
raw_val_dict
else
None
device_id
=
raw_val_dict
[
"device"
][
"device_id"
]
self
.
transfer_update_recommend_tag_list
(
device_id
,
user_feature
,
user_id
,
user_id
=
raw_val_dict
[
"user_id"
]
if
"user_id"
in
raw_val_dict
else
None
tag_list
,
self
.
transfer_update_recommend_tag_list
(
device_id
,
user_feature
,
user_id
,
10
)
tag_list
,
# 创建问题关注标签关键字进linucb
10
)
elif
'SYS'
in
data
and
'APP'
in
data
and
'action'
in
data
[
'SYS'
]
and
\
# 创建问题关注标签关键字进linucb
"venus/sun/pictorial/edit"
in
data
[
'SYS'
][
'action'
]:
elif
'SYS'
in
data
and
'APP'
in
data
and
'action'
in
data
[
'SYS'
]
and
\
tag_ids
=
list
(
raw_val_dict
[
"APP"
]
.
get
(
"tag_ids"
,
[]))
"venus/sun/pictorial/edit"
in
data
[
'SYS'
][
'action'
]:
tag_list
=
list
(
Tag
.
objects
.
using
(
settings
.
SLAVE1_DB_NAME
)
.
filter
(
tag_ids
=
list
(
raw_val_dict
[
"APP"
]
.
get
(
"tag_ids"
,
[]))
id__in
=
tag_ids
,
is_online
=
True
,
is_deleted
=
False
,
tag_list
=
list
(
Tag
.
objects
.
using
(
settings
.
SLAVE1_DB_NAME
)
.
filter
(
is_category
=
False
)
.
values_list
(
"id"
))
id__in
=
tag_ids
,
is_online
=
True
,
is_deleted
=
False
,
device_id
=
raw_val_dict
[
"device"
][
"device_id"
]
is_category
=
False
)
.
values_list
(
"id"
))
user_id
=
raw_val_dict
[
"user_id"
]
if
"user_id"
in
raw_val_dict
else
None
device_id
=
raw_val_dict
[
"device"
][
"device_id"
]
self
.
transfer_update_recommend_tag_list
(
device_id
,
user_feature
,
user_id
,
user_id
=
raw_val_dict
[
"user_id"
]
if
"user_id"
in
raw_val_dict
else
None
tag_list
,
self
.
transfer_update_recommend_tag_list
(
device_id
,
user_feature
,
user_id
,
20
)
tag_list
,
20
)
else
:
else
:
if
msg
:
if
msg
:
logging
.
warning
(
"unknown type msg:
%
s"
%
raw_val_dict
.
get
(
"type"
,
"missing type"
))
logging
.
warning
(
"unknown type msg:
%
s"
%
raw_val_dict
.
get
(
"type"
,
"missing type"
))
...
...
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