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
954ca95f
Commit
954ca95f
authored
Apr 12, 2019
by
Kai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fix
parent
a946d1e9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
24 deletions
+35
-24
collect_data.py
linucb/views/collect_data.py
+15
-2
topic.py
search/views/topic.py
+20
-22
No files found.
linucb/views/collect_data.py
View file @
954ca95f
...
@@ -98,12 +98,25 @@ class CollectData(object):
...
@@ -98,12 +98,25 @@ class CollectData(object):
tag_id_list
=
recommend_tag_list
[
0
:
100
]
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
)
tag_topic_id_list
=
ESPerform
.
get_tag_topic_list
(
tag_id_list
,
have_read_topic_id_list
)
topic_recommend_redis_key
=
self
.
linucb_recommend_topic_id_prefix
+
str
(
device_id
)
topic_recommend_redis_key
=
self
.
linucb_recommend_topic_id_prefix
+
str
(
device_id
)
if
click_topic_tag_list
:
if
len
(
click_topic_tag_list
)
>
0
:
tag_topic_id_list
=
click_topic_tag_list
+
tag_topic_id_list
else
:
redis_topic_data_dict
=
redis_client
.
hgetall
(
topic_recommend_redis_key
)
redis_topic_list
=
list
()
cursor
=
-
1
if
b
"data"
in
redis_topic_data_dict
:
redis_topic_list
=
json
.
loads
(
redis_topic_data_dict
[
b
"data"
])
if
redis_topic_data_dict
[
b
"data"
]
else
[]
cursor
=
redis_topic_data_dict
[
b
"cursor"
]
if
cursor
==
0
and
len
(
redis_topic_list
)
>
0
:
tag_topic_id_list
=
redis_topic_list
[:
2
]
+
tag_topic_id_list
redis_data_dict
=
{
redis_data_dict
=
{
"data"
:
json
.
dumps
(
tag_topic_id_list
),
"data"
:
json
.
dumps
(
tag_topic_id_list
),
"cursor"
:
0
"cursor"
:
0
}
}
redis_client
.
hmset
(
topic_recommend_redis_key
,
redis_data_dict
)
redis_client
.
hmset
(
topic_recommend_redis_key
,
redis_data_dict
)
return
True
return
True
except
:
except
:
...
...
search/views/topic.py
View file @
954ca95f
...
@@ -59,7 +59,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
...
@@ -59,7 +59,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
redis_field_val_list
=
redis_client
.
hmget
(
redis_key
,
redis_field_list
)
redis_field_val_list
=
redis_client
.
hmget
(
redis_key
,
redis_field_list
)
topic_recommend_redis_key
=
"physical:linucb:topic_recommend:device_id:"
+
str
(
device_id
)
topic_recommend_redis_key
=
"physical:linucb:topic_recommend:device_id:"
+
str
(
device_id
)
click_recommend_redis_key
=
"physical:click_recommend:device_id:"
+
str
(
device_id
)
#
click_recommend_redis_key = "physical:click_recommend:device_id:" + str(device_id)
# recommend_tag_dict = dict()
# recommend_tag_dict = dict()
...
@@ -77,20 +77,20 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
...
@@ -77,20 +77,20 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
recommend_topic_list
=
recommend_topic_id_list
[
cursor
:
newcursor
]
recommend_topic_list
=
recommend_topic_id_list
[
cursor
:
newcursor
]
redis_client
.
hset
(
topic_recommend_redis_key
,
"cursor"
,
newcursor
)
redis_client
.
hset
(
topic_recommend_redis_key
,
"cursor"
,
newcursor
)
click_recommend_topic_id_list
=
list
()
#
click_recommend_topic_id_list = list()
click_recommend_topic_list
=
list
()
#
click_recommend_topic_list = list()
#
click_recommend_topic_dict
=
redis_client
.
hgetall
(
click_recommend_redis_key
)
#
click_recommend_topic_dict = redis_client.hgetall(click_recommend_redis_key)
if
b
"data"
in
click_recommend_topic_dict
:
#
if b"data" in click_recommend_topic_dict:
click_recommend_topic_id_list
=
json
.
loads
(
click_recommend_topic_dict
[
b
"data"
])
#
click_recommend_topic_id_list = json.loads(click_recommend_topic_dict[b"data"])
cursor
=
int
(
str
(
click_recommend_topic_dict
[
b
"cursor"
],
encoding
=
"utf-8"
))
#
cursor = int(str(click_recommend_topic_dict[b"cursor"], encoding="utf-8"))
newcursor
=
cursor
+
2
#
newcursor = cursor + 2
if
newcursor
<
4
and
len
(
click_recommend_topic_id_list
)
==
2
:
#
if newcursor < 4 and len(click_recommend_topic_id_list) ==2:
for
i
in
range
(
0
,
2
):
#
for i in range(0,2):
click_recommend_topic_list
.
append
(
click_recommend_topic_id_list
[
i
])
#
click_recommend_topic_list.append(click_recommend_topic_id_list[i])
redis_client
.
hset
(
click_recommend_redis_key
,
"cursor"
,
newcursor
)
#
redis_client.hset(click_recommend_redis_key, "cursor", newcursor)
combine_recommend_topic_list_tmp
=
click_recommend_topic_list
.
extend
(
recommend_topic_list
)
#
combine_recommend_topic_list_tmp = click_recommend_topic_list.extend(recommend_topic_list)
combine_recommend_topic_list
=
combine_recommend_topic_list_tmp
[
0
:
5
]
#
combine_recommend_topic_list = combine_recommend_topic_list_tmp[0:5]
have_read_topic_id_list
=
list
()
have_read_topic_id_list
=
list
()
if
redis_field_val_list
[
0
]:
if
redis_field_val_list
[
0
]:
...
@@ -109,11 +109,13 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
...
@@ -109,11 +109,13 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
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
[]
size
=
size
-
len
(
combine_recommend_topic_list
)
if
len
(
recommend_topic_list
)
>
0
:
size
=
size
-
len
(
recommend_topic_list
)
have_read_topic_id_list
.
extend
(
recommend_topic_list
)
topic_id_list
=
TopicUtils
.
get_recommend_topic_ids
(
user_id
=
user_id
,
tag_id
=
tag_id
,
offset
=
offset
,
size
=
size
,
topic_id_list
=
TopicUtils
.
get_recommend_topic_ids
(
user_id
=
user_id
,
tag_id
=
tag_id
,
offset
=
offset
,
size
=
size
,
single_size
=
size
,
query
=
query
,
query_type
=
query_type
,
single_size
=
size
,
query
=
query
,
query_type
=
query_type
,
filter_topic_id_list
=
have_read_topic_id_list
,
filter_topic_id_list
=
have_read_topic_id_list
,
recommend_tag_list
=
combine_
recommend_topic_list
,
recommend_tag_list
=
recommend_topic_list
,
user_similar_score_list
=
user_similar_score_redis_list
,
index_type
=
"topic"
,
routing
=
"4,5"
,
attention_tag_list
=
attention_tag_list
)
user_similar_score_list
=
user_similar_score_redis_list
,
index_type
=
"topic"
,
routing
=
"4,5"
,
attention_tag_list
=
attention_tag_list
)
have_read_group_id_set
=
set
()
have_read_group_id_set
=
set
()
have_read_user_id_set
=
set
()
have_read_user_id_set
=
set
()
...
@@ -155,11 +157,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
...
@@ -155,11 +157,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
# else:
# else:
# break
# break
topic_id_list
.
extend
(
recommend_topic_list
)
topic_id_list
.
extend
(
combine_recommend_topic_list
)
# recommend_topic_list.extend(topic_id_list)
# recommend_topic_list.extend(topic_id_list)
have_read_topic_id_list
.
extend
(
topic_id_list
)
have_read_topic_id_list
.
extend
(
topic_id_list
)
if
len
(
have_read_topic_id_list
)
>
30000
:
if
len
(
have_read_topic_id_list
)
>
30000
:
...
...
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