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
7543e7ec
Commit
7543e7ec
authored
Dec 04, 2018
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
5d71c369
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
21 deletions
+46
-21
topic.py
search/utils/topic.py
+12
-0
pick.py
search/views/pick.py
+22
-19
topic.py
search/views/topic.py
+12
-2
No files found.
search/utils/topic.py
View file @
7543e7ec
...
@@ -158,6 +158,12 @@ class TopicUtils(object):
...
@@ -158,6 +158,12 @@ class TopicUtils(object):
}
}
}
}
},
},
"gauss"
:
{
"update_time"
:
{
"scale"
:
"1d"
,
"decay"
:
0.5
}
},
"score_mode"
:
"sum"
,
"score_mode"
:
"sum"
,
"boost_mode"
:
"sum"
,
"boost_mode"
:
"sum"
,
"functions"
:
functions_list
"functions"
:
functions_list
...
@@ -274,6 +280,12 @@ class TopicUtils(object):
...
@@ -274,6 +280,12 @@ class TopicUtils(object):
}
}
}
}
},
},
"gauss"
:{
"update_time"
:{
"scale"
:
"1d"
,
"decay"
:
0.5
}
},
"score_mode"
:
"sum"
,
"score_mode"
:
"sum"
,
"boost_mode"
:
"sum"
,
"boost_mode"
:
"sum"
,
"functions"
:
functions_list
"functions"
:
functions_list
...
...
search/views/pick.py
View file @
7543e7ec
...
@@ -13,21 +13,22 @@ from search.utils.common import PickType
...
@@ -13,21 +13,22 @@ from search.utils.common import PickType
@bind
(
"physical/search/pick_celebrity"
)
@bind
(
"physical/search/pick_celebrity"
)
def
pick_celebrity
(
user_id
,
pick_id
,
offset
=
0
,
size
=
10
):
def
pick_celebrity
(
user_id
,
pick_id
,
offset
=
0
,
size
=
10
):
try
:
try
:
redis_key
=
"physical:pick_celebrity:"
+
"user_id:"
+
str
(
user_id
)
+
":pick_id:"
+
str
(
pick_id
)
have_read_pick_celebrity_ids
=
list
()
have_read_pick_celebrity_ids
=
list
()
try
:
redis_key
=
"physical:pick_celebrity:"
+
"user_id:"
+
str
(
user_id
)
+
":pick_id:"
+
str
(
pick_id
)
redis_celebrity_info
=
redis_client
.
get
(
redis_key
)
if
redis_celebrity_info
:
if
user_id
!=
-
1
:
have_read_pick_celebrity_ids
=
json
.
loads
(
redis_celebrity_info
)
try
:
except
:
redis_celebrity_info
=
redis_client
.
get
(
redis_key
)
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
if
redis_celebrity_info
:
pass
have_read_pick_celebrity_ids
=
json
.
loads
(
redis_celebrity_info
)
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
pass
recommend_pick_celebrity_list
=
PickUtils
.
get_recommend_celebrity_id_list
(
pick_id
,
have_read_pick_celebrity_ids
,
offset
,
size
)
recommend_pick_celebrity_list
=
PickUtils
.
get_recommend_celebrity_id_list
(
pick_id
,
have_read_pick_celebrity_ids
,
offset
,
size
)
if
len
(
recommend_pick_celebrity_list
)
>
0
:
if
len
(
recommend_pick_celebrity_list
)
>
0
and
user_id
!=-
1
:
total_read_celebrity_ids
=
have_read_pick_celebrity_ids
+
recommend_pick_celebrity_list
total_read_celebrity_ids
=
have_read_pick_celebrity_ids
+
recommend_pick_celebrity_list
PickUtils
.
refresh_redis_data
(
have_read_celebrity_list
=
total_read_celebrity_ids
,
PickUtils
.
refresh_redis_data
(
have_read_celebrity_list
=
total_read_celebrity_ids
,
redis_cli
=
redis_client
,
redis_key
=
redis_key
)
redis_cli
=
redis_client
,
redis_key
=
redis_key
)
...
@@ -41,16 +42,18 @@ def pick_celebrity(user_id,pick_id,offset=0,size=10):
...
@@ -41,16 +42,18 @@ def pick_celebrity(user_id,pick_id,offset=0,size=10):
@bind
(
"physical/search/pick_topic"
)
@bind
(
"physical/search/pick_topic"
)
def
pick_topic
(
user_id
,
pick_id
,
offset
=
0
,
size
=
10
):
def
pick_topic
(
user_id
,
pick_id
,
offset
=
0
,
size
=
10
):
try
:
try
:
redis_key
=
"physical:pick_topic:"
+
"user_id:"
+
str
(
user_id
)
+
":pick_id:"
+
str
(
pick_id
)
have_read_pick_topic_ids
=
list
()
have_read_pick_topic_ids
=
list
()
try
:
redis_key
=
"physical:pick_topic:"
+
"user_id:"
+
str
(
user_id
)
+
":pick_id:"
+
str
(
pick_id
)
redis_celebrity_info
=
redis_client
.
get
(
redis_key
)
if
redis_celebrity_info
:
if
user_id
!=
-
1
:
have_read_pick_topic_ids
=
json
.
loads
(
redis_celebrity_info
)
try
:
except
:
redis_celebrity_info
=
redis_client
.
get
(
redis_key
)
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
if
redis_celebrity_info
:
have_read_pick_topic_ids
=
json
.
loads
(
redis_celebrity_info
)
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
pass
q
=
dict
()
q
=
dict
()
functions_list
=
[
functions_list
=
[
...
@@ -102,7 +105,7 @@ def pick_topic(user_id,pick_id,offset=0,size=10):
...
@@ -102,7 +105,7 @@ def pick_topic(user_id,pick_id,offset=0,size=10):
if
len
(
result_dict
[
"hits"
])
>
0
:
if
len
(
result_dict
[
"hits"
])
>
0
:
recommend_pick_topic_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_dict
[
"hits"
]]
recommend_pick_topic_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_dict
[
"hits"
]]
if
len
(
recommend_pick_topic_list
)
>
0
:
if
len
(
recommend_pick_topic_list
)
>
0
and
user_id
!=-
1
:
total_read_topic_ids
=
have_read_pick_topic_ids
+
recommend_pick_topic_list
total_read_topic_ids
=
have_read_pick_topic_ids
+
recommend_pick_topic_list
PickUtils
.
refresh_redis_data
(
have_read_celebrity_list
=
total_read_topic_ids
,
PickUtils
.
refresh_redis_data
(
have_read_celebrity_list
=
total_read_topic_ids
,
redis_cli
=
redis_client
,
redis_key
=
redis_key
)
redis_cli
=
redis_client
,
redis_key
=
redis_key
)
...
...
search/views/topic.py
View file @
7543e7ec
...
@@ -13,7 +13,11 @@ from libs.cache import redis_client
...
@@ -13,7 +13,11 @@ from libs.cache import redis_client
@bind
(
"physical/search/home_recommend"
)
@bind
(
"physical/search/home_recommend"
)
def
home_recommend
(
session_id
=
""
,
user_id
=-
1
,
offset
=
0
,
size
=
10
):
def
home_recommend
(
session_id
=
""
,
user_id
=-
1
,
offset
=
0
,
size
=
10
):
"""
"""
:remark:首页推荐,目前只推荐日记,缺少小组打散策略
:remark:首页推荐,目前只推荐日记
:param session_id:
:param user_id:
:param offset:
:param size:
:return:
:return:
"""
"""
try
:
try
:
...
@@ -57,6 +61,8 @@ def home_recommend(session_id="",user_id=-1,offset=0,size=10):
...
@@ -57,6 +61,8 @@ def home_recommend(session_id="",user_id=-1,offset=0,size=10):
"have_read_topic_id"
:
json
.
dumps
(
list
(
have_read_topic_id_tuple
))
"have_read_topic_id"
:
json
.
dumps
(
list
(
have_read_topic_id_tuple
))
}
}
redis_client
.
hmset
(
redis_key
,
redis_dict
)
redis_client
.
hmset
(
redis_key
,
redis_dict
)
# 每个session key保存15分钟
redis_client
.
expire
(
redis_key
,
15
*
60
*
60
)
return
{
"recommend_topic_ids"
:
recommend_topic_ids
}
return
{
"recommend_topic_ids"
:
recommend_topic_ids
}
except
:
except
:
...
@@ -67,7 +73,9 @@ def home_recommend(session_id="",user_id=-1,offset=0,size=10):
...
@@ -67,7 +73,9 @@ def home_recommend(session_id="",user_id=-1,offset=0,size=10):
@bind
(
"physical/search/home_query"
)
@bind
(
"physical/search/home_query"
)
def
home_query
(
session_id
=
""
,
user_id
=-
1
,
query
=
""
,
offset
=
0
,
size
=
10
):
def
home_query
(
session_id
=
""
,
user_id
=-
1
,
query
=
""
,
offset
=
0
,
size
=
10
):
"""
"""
:remark 首页搜索排序,没有做打散,搜索逻辑优化
:remark:首页搜索,目前只推荐日记
:param session_id:
:param user_id:
:param query:
:param query:
:param offset:
:param offset:
:param size:
:param size:
...
@@ -114,6 +122,8 @@ def home_query(session_id="",user_id=-1,query="",offset=0,size=10):
...
@@ -114,6 +122,8 @@ def home_query(session_id="",user_id=-1,query="",offset=0,size=10):
"have_read_topic_id"
:
json
.
dumps
(
list
(
have_read_topic_id_tuple
))
"have_read_topic_id"
:
json
.
dumps
(
list
(
have_read_topic_id_tuple
))
}
}
redis_client
.
hmset
(
redis_key
,
redis_dict
)
redis_client
.
hmset
(
redis_key
,
redis_dict
)
# 每个session key保存15分钟
redis_client
.
expire
(
redis_key
,
15
*
60
*
60
)
return
{
"recommend_topic_ids"
:
recommend_topic_ids
}
return
{
"recommend_topic_ids"
:
recommend_topic_ids
}
except
:
except
:
...
...
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