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
钟尚武
physical
Commits
b51da630
Commit
b51da630
authored
Apr 12, 2019
by
Kai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
e0dc1c54
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
9 deletions
+31
-9
misc.xml
.idea/misc.xml
+1
-1
physical.iml
.idea/physical.iml
+1
-1
collect_data.py
linucb/views/collect_data.py
+14
-7
topic.py
search/views/topic.py
+15
-0
No files found.
.idea/misc.xml
View file @
b51da630
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ProjectRootManager"
version=
"2"
project-jdk-name=
"Python 3.6 (
venv
)"
project-jdk-type=
"Python SDK"
/>
<component
name=
"ProjectRootManager"
version=
"2"
project-jdk-name=
"Python 3.6 (
physical1
)"
project-jdk-type=
"Python SDK"
/>
<component
name=
"PyCharmProfessionalAdvertiser"
>
<option
name=
"shown"
value=
"true"
/>
</component>
...
...
.idea/physical.iml
View file @
b51da630
...
...
@@ -2,7 +2,7 @@
<module
type=
"PYTHON_MODULE"
version=
"4"
>
<component
name=
"NewModuleRootManager"
>
<content
url=
"file://$MODULE_DIR$"
/>
<orderEntry
type=
"
inheritedJdk
"
/>
<orderEntry
type=
"
jdk"
jdkName=
"Python 3.6 (physical1)"
jdkType=
"Python SDK
"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
<component
name=
"TestRunnerService"
>
...
...
linucb/views/collect_data.py
View file @
b51da630
...
...
@@ -50,7 +50,7 @@ class CollectData(object):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
dict
()
def
update_recommend_tag_list
(
self
,
device_id
,
user_feature
=
None
):
def
update_recommend_tag_list
(
self
,
device_id
,
user_feature
=
None
,
click_topic_tag_list
=
None
):
try
:
recommend_tag_set
=
set
()
recommend_tag_list
=
list
()
...
...
@@ -74,8 +74,13 @@ class CollectData(object):
have_read_topic_id_list
=
Tools
.
get_have_read_topic_id_list
(
device_id
,
-
1
,
TopicPageType
.
HOME_RECOMMEND
)
recommend_topic_id_list
=
list
()
if
click_topic_tag_list
:
recommend_topic_id_list_click
=
ESPerform
.
get_tag_topic_list
(
click_topic_tag_list
,
have_read_topic_id_list
)
recommend_topic_id_list
.
extend
(
recommend_topic_id_list_click
[
0
:
2
])
tag_id_list
=
recommend_tag_list
[
0
:
100
]
tag_topic_id_list
=
ESPerform
.
get_tag_topic_list
(
tag_id_list
,
have_read_topic_id_list
)
recommend_topic_id_list
.
extend
(
tag_topic_id_list
)
# for index in range(0,100):
# recommend_topic_id_list_es = list()
# for tag_id in recommend_tag_list[0:100]:
...
...
@@ -104,7 +109,7 @@ class CollectData(object):
# recommend_topic_id_list.extend(recommend_topic_id_list_es)
topic_recommend_redis_key
=
self
.
linucb_recommend_topic_id_prefix
+
str
(
device_id
)
redis_data_dict
=
{
"data"
:
json
.
dumps
(
tag
_topic_id_list
),
"data"
:
json
.
dumps
(
recommend
_topic_id_list
),
"cursor"
:
0
}
redis_client
.
hmset
(
topic_recommend_redis_key
,
redis_data_dict
)
...
...
@@ -144,13 +149,15 @@ class CollectData(object):
logging
.
info
(
"consume topic_id:
%
s,device_id:
%
s"
%
(
str
(
topic_id
),
str
(
device_id
)))
tag_list
=
list
()
click_topic_tag_list
=
list
()
click_sql_query_results
=
TopicTag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
topic_id
=
topic_id
)
.
values_list
(
"tag_id"
,
"is_online"
)
for
tag_id
,
is_online
in
click_sql_query_results
:
if
is_online
:
# tag_sql_query_results = Tag.objects.using(settings.SLAVE_DB_NAME).filter(id=tag_id).values_list("id","collection","is_ai")
# for id,collection,is_ai in tag_sql_query_results:
# if collection == 1 or is_ai == 1:
tag_list
.
append
(
tag_id
)
tag_list
.
append
(
tag_id
)
tag_sql_query_results
=
Tag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
id
=
tag_id
)
.
values_list
(
"id"
,
"collection"
,
"is_ai"
)
for
id
,
collection
,
is_ai
in
tag_sql_query_results
:
if
collection
==
1
or
is_ai
==
1
:
click_topic_tag_list
.
append
(
id
)
is_click
=
1
is_vote
=
0
...
...
@@ -163,7 +170,7 @@ class CollectData(object):
self
.
update_user_linucb_tag_info
(
reward
,
device_id
,
tag_id
,
user_feature
)
# 更新该用户的推荐tag数据,放在 更新完成user tag行为信息之后
self
.
update_recommend_tag_list
(
device_id
,
user_feature
)
self
.
update_recommend_tag_list
(
device_id
,
user_feature
,
click_topic_tag_list
)
elif
"type"
in
raw_val_dict
and
"page_precise_exposure"
==
raw_val_dict
[
"type"
]:
if
isinstance
(
raw_val_dict
[
"params"
][
"exposure_cards"
],
str
):
exposure_cards_list
=
json
.
loads
(
raw_val_dict
[
"params"
][
"exposure_cards"
])
...
...
search/views/topic.py
View file @
b51da630
...
...
@@ -67,6 +67,21 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
# recommend_tag_dict = json.loads(str(tag_recommend_val, encoding="utf-8"))
recommend_topic_list
=
list
()
recommend_topic_dict
=
redis_client
.
hgetall
(
topic_recommend_redis_key
)
if
b
"data"
in
recommend_topic_dict
:
recommend_topic_id_list
=
json
.
loads
(
recommend_topic_dict
[
b
"data"
])
...
...
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