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
788c96d7
Commit
788c96d7
authored
Apr 29, 2019
by
黄凯
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hk' into 'test'
Hk See merge request alpha/physical!312
parents
22d7bcc2
0e2ce5e1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
9 deletions
+14
-9
es.py
libs/es.py
+5
-1
collect_data.py
linucb/views/collect_data.py
+7
-6
topic.py
search/views/topic.py
+2
-2
No files found.
libs/es.py
View file @
788c96d7
...
@@ -430,7 +430,11 @@ class ESPerform(object):
...
@@ -430,7 +430,11 @@ class ESPerform(object):
topic_id_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_dict
[
"hits"
]]
topic_id_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_dict
[
"hits"
]]
# logging.info("topic_id_list:%s" % str(topic_id_list))
# logging.info("topic_id_list:%s" % str(topic_id_list))
topic_id_dict
=
[{
str
(
item
[
"_source"
][
"id"
]):
item
[
"_source"
][
"user_id"
]}
for
item
in
result_dict
[
"hits"
]]
# topic_id_dict = [{str(item["_source"]["id"]):item["_source"]["user_id"]} for item in result_dict["hits"]]
topic_id_dict
=
dict
()
for
item
in
result_dict
[
"hits"
]:
topic_id_dict
[
str
(
item
[
"_source"
][
"id"
])]
=
item
[
"_source"
][
"user_id"
]
logging
.
info
(
"topic_id_list:
%
s"
%
str
(
topic_id_dict
))
logging
.
info
(
"topic_id_list:
%
s"
%
str
(
topic_id_dict
))
return
topic_id_list
,
topic_id_dict
return
topic_id_list
,
topic_id_dict
...
...
linucb/views/collect_data.py
View file @
788c96d7
...
@@ -74,9 +74,9 @@ class CollectData(object):
...
@@ -74,9 +74,9 @@ class CollectData(object):
have_read_topic_id_list
.
extend
(
promote_recommend_topic_id_list
)
have_read_topic_id_list
.
extend
(
promote_recommend_topic_id_list
)
recommend_topic_id_list
=
list
()
recommend_topic_id_list
=
list
()
recommend_topic_id_list_dict
=
lis
t
()
recommend_topic_id_list_dict
=
dic
t
()
recommend_topic_id_list_click
=
list
()
recommend_topic_id_list_click
=
list
()
recommend_topic_id_list_click_dict
=
lis
t
()
recommend_topic_id_list_click_dict
=
dic
t
()
if
click_topic_tag_list
:
if
click_topic_tag_list
:
...
@@ -85,7 +85,7 @@ class CollectData(object):
...
@@ -85,7 +85,7 @@ class CollectData(object):
have_read_topic_id_list
,
size
=
2
)
have_read_topic_id_list
,
size
=
2
)
if
len
(
recommend_topic_id_list_click
)
>
0
:
if
len
(
recommend_topic_id_list_click
)
>
0
:
recommend_topic_id_list
.
extend
(
recommend_topic_id_list_click
)
recommend_topic_id_list
.
extend
(
recommend_topic_id_list_click
)
recommend_topic_id_list_dict
.
extend
(
recommend_topic_id_list_click_dict
)
recommend_topic_id_list_dict
.
update
(
recommend_topic_id_list_click_dict
)
have_read_topic_id_list
.
extend
(
recommend_topic_id_list_click
)
have_read_topic_id_list
.
extend
(
recommend_topic_id_list_click
)
click_recommend_redis_key
=
self
.
click_recommend_redis_key_prefix
+
str
(
device_id
)
click_recommend_redis_key
=
self
.
click_recommend_redis_key_prefix
+
str
(
device_id
)
click_redis_data_dict
=
{
click_redis_data_dict
=
{
...
@@ -109,7 +109,7 @@ class CollectData(object):
...
@@ -109,7 +109,7 @@ class CollectData(object):
if
len
(
recommend_topic_id_list
)
==
0
and
cursor
==
0
and
len
(
redis_topic_list
)
>
0
:
if
len
(
recommend_topic_id_list
)
==
0
and
cursor
==
0
and
len
(
redis_topic_list
)
>
0
:
have_read_topic_id_list
.
extend
(
redis_topic_list
[:
2
])
have_read_topic_id_list
.
extend
(
redis_topic_list
[:
2
])
tag_topic_dict
=
lis
t
()
tag_topic_dict
=
dic
t
()
if
len
(
new_user_click_tag_list
)
>
0
:
if
len
(
new_user_click_tag_list
)
>
0
:
tag_topic_id_list
,
tag_topic_dict
=
ESPerform
.
get_tag_topic_list_dict
(
new_user_click_tag_list
,
have_read_topic_id_list
)
tag_topic_id_list
,
tag_topic_dict
=
ESPerform
.
get_tag_topic_list_dict
(
new_user_click_tag_list
,
have_read_topic_id_list
)
...
@@ -119,7 +119,7 @@ class CollectData(object):
...
@@ -119,7 +119,7 @@ class CollectData(object):
if
len
(
recommend_topic_id_list
)
>
0
or
len
(
new_user_click_tag_list
)
>
0
:
if
len
(
recommend_topic_id_list
)
>
0
or
len
(
new_user_click_tag_list
)
>
0
:
tag_topic_id_list
=
recommend_topic_id_list
+
tag_topic_id_list
tag_topic_id_list
=
recommend_topic_id_list
+
tag_topic_id_list
tag_topic_dict
=
recommend_topic_id_list_dict
+
tag_topic_dict
tag_topic_dict
=
recommend_topic_id_list_dict
.
update
(
tag_topic_dict
)
redis_data_dict
=
{
redis_data_dict
=
{
"data"
:
json
.
dumps
(
tag_topic_id_list
),
"data"
:
json
.
dumps
(
tag_topic_id_list
),
"datadict"
:
json
.
dumps
(
tag_topic_dict
),
"datadict"
:
json
.
dumps
(
tag_topic_dict
),
...
@@ -128,7 +128,8 @@ class CollectData(object):
...
@@ -128,7 +128,8 @@ class CollectData(object):
redis_client
.
hmset
(
topic_recommend_redis_key
,
redis_data_dict
)
redis_client
.
hmset
(
topic_recommend_redis_key
,
redis_data_dict
)
else
:
else
:
if
cursor
<=
0
and
len
(
redis_topic_list
)
>
0
:
if
cursor
<=
0
and
len
(
redis_topic_list
)
>
0
:
tag_topic_dict
=
redis_topic_list
[:
2
]
+
tag_topic_dict
tag_topic_dict
=
list
()
tag_topic_dict
=
redis_topic_list
[:
2
]
tag_topic_dict
=
list
(
set
(
tag_topic_dict
))
tag_topic_dict
=
list
(
set
(
tag_topic_dict
))
return
True
return
True
...
...
search/views/topic.py
View file @
788c96d7
...
@@ -101,8 +101,8 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
...
@@ -101,8 +101,8 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
if
b
"datadict"
in
recommend_topic_dict
:
if
b
"datadict"
in
recommend_topic_dict
:
recommend_topic_id_dict
=
json
.
loads
(
recommend_topic_dict
[
b
"datadict"
])
recommend_topic_id_dict
=
json
.
loads
(
recommend_topic_dict
[
b
"datadict"
])
if
len
(
recommend_topic_list
)
==
6
:
if
len
(
recommend_topic_list
)
==
6
:
for
i
in
recommend_topic_
id_dic
t
:
for
i
in
recommend_topic_
lis
t
:
recommend_topic_user_list
.
append
(
i
.
values
()
)
recommend_topic_user_list
.
append
(
recommend_topic_id_dict
[
str
(
i
)]
)
# 用户关注标签
# 用户关注标签
redis_tag_data
=
redis_client
.
hget
(
"physical:linucb:register_user_tag_info"
,
user_id
)
redis_tag_data
=
redis_client
.
hget
(
"physical:linucb:register_user_tag_info"
,
user_id
)
attention_tag_list
=
json
.
loads
(
redis_tag_data
)
if
redis_tag_data
else
[]
attention_tag_list
=
json
.
loads
(
redis_tag_data
)
if
redis_tag_data
else
[]
...
...
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