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
6ad00313
Commit
6ad00313
authored
Sep 20, 2019
by
高雅喆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加策略类型的枚举
parent
1d43ae93
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
topic.py
search/views/topic.py
+12
-11
No files found.
search/views/topic.py
View file @
6ad00313
...
...
@@ -19,6 +19,7 @@ from trans2es.models.tag import Tag
from
search.views.tag
import
get_same_tagset_ids
from
linucb.views.collect_data
import
CollectData
from
linucb.views.linucb
import
LinUCB
from
alpha_types.physical.enum
import
STRATEGY_TYPE
def
get_discover_page_topic_ids
(
user_id
,
device_id
,
size
,
query_type
=
TopicPageType
.
FIND_PAGE
):
...
...
@@ -56,7 +57,7 @@ def get_discover_page_topic_ids(user_id, device_id, size, query_type=TopicPageTy
def
get_home_recommend_topic_ids
(
user_id
,
device_id
,
tag_id
,
offset
,
size
,
query
=
None
,
query_type
=
TopicPageType
.
HOME_RECOMMEND
,
promote_topic_list
=
[],
disable_collpase
=
False
,
usefulrecall
=-
1
,
useful_tag_list
=
[],
has_score
=
False
,
is_gray
=-
1
):
usefulrecall
=-
1
,
useful_tag_list
=
[],
has_score
=
False
,
gray_list
=
[]
):
try
:
topic_star_routing
=
"6"
index_type
=
"topic-high-star"
...
...
@@ -221,7 +222,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
# 失效时间为第二天凌晨3点
# if redis_client.ttl(redis_key)<0:
today
=
datetime
.
datetime
.
strptime
(
str
(
datetime
.
date
.
today
()),
"
%
Y-
%
m-
%
d"
)
if
is_gray
==
0
:
if
STRATEGY_TYPE
.
READ_GRAY
in
gray_list
:
end_day
=
today
+
datetime
.
timedelta
(
days
=
10
)
else
:
end_day
=
today
+
datetime
.
timedelta
(
days
=
1
)
...
...
@@ -254,7 +255,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
return
[],
[]
def
get_home_recommend_pictorial_ids
(
user_id
=-
1
,
device_id
=
""
,
size
=
4
,
is_gray
=-
1
):
def
get_home_recommend_pictorial_ids
(
user_id
=-
1
,
device_id
=
""
,
size
=
4
,
gray_list
=
[]
):
try
:
pictorial_recommend_redis_key
=
"physical:linucb:pictorial_recommend:device_id:"
+
str
(
device_id
)
have_read_lin_pictorial_id_list
=
get_have_read_lin_pictorial_id_list
(
device_id
,
user_id
,
...
...
@@ -278,7 +279,7 @@ def get_home_recommend_pictorial_ids(user_id=-1, device_id="", size=4, is_gray=-
redis_field_list
=
'have_read_pictorial_list'
redis_client
.
hset
(
redis_key
,
redis_field_list
,
have_read_lin_pictorial_id_list
)
today
=
datetime
.
datetime
.
strptime
(
str
(
datetime
.
date
.
today
()),
"
%
Y-
%
m-
%
d"
)
if
is_gray
==
0
:
if
STRATEGY_TYPE
.
READ_GRAY
in
gray_list
:
end_day
=
today
+
datetime
.
timedelta
(
days
=
10
)
else
:
end_day
=
today
+
datetime
.
timedelta
(
days
=
1
)
...
...
@@ -374,7 +375,7 @@ def query_tag_id_by_topic(offset=0, size=10, topic_id_list=[], user_id=-1):
@bind
(
"physical/search/home_recommend"
)
def
home_recommend
(
device_id
=
""
,
user_id
=-
1
,
offset
=
0
,
lin_pictorial_count
=
4
,
size
=
10
,
query_type
=
TopicPageType
.
HOME_RECOMMEND
,
promote_topic_list
=
[],
usefulrecall
=-
1
,
useful_tag_list
=
[],
is_debug
=
False
,
is_gray
=-
1
):
promote_topic_list
=
[],
usefulrecall
=-
1
,
useful_tag_list
=
[],
is_debug
=
False
,
gray_list
=
[]
):
"""
:remark:首页推荐,目前只推荐日记
:param session_id:
...
...
@@ -415,7 +416,7 @@ def home_recommend(device_id="", user_id=-1, offset=0, lin_pictorial_count=4, si
else
:
if
usefulrecall
!=
-
1
and
len
(
useful_tag_list
)
>
0
:
recommend_pictorial_ids
=
get_home_recommend_pictorial_ids
(
user_id
,
device_id
,
lin_pictorial_count
,
is_gray
=
is_gray
)
recommend_pictorial_ids
=
get_home_recommend_pictorial_ids
(
user_id
,
device_id
,
lin_pictorial_count
,
gray_list
=
gray_list
)
size
=
size
-
len
(
recommend_pictorial_ids
)
if
is_debug
:
has_score
=
True
...
...
@@ -426,7 +427,7 @@ def home_recommend(device_id="", user_id=-1, offset=0, lin_pictorial_count=4, si
query_type
=
query_type
,
promote_topic_list
=
promote_topic_list
,
usefulrecall
=
usefulrecall
,
useful_tag_list
=
useful_tag_list
,
has_score
=
has_score
,
is_gray
=
is_gray
)
useful_tag_list
=
useful_tag_list
,
has_score
=
has_score
,
gray_list
=
gray_list
)
else
:
has_score
=
False
...
...
@@ -439,7 +440,7 @@ def home_recommend(device_id="", user_id=-1, offset=0, lin_pictorial_count=4, si
promote_topic_list
=
promote_topic_list
,
usefulrecall
=
usefulrecall
,
useful_tag_list
=
useful_tag_list
,
has_score
=
has_score
,
is_gray
=
is_gray
)
has_score
=
has_score
,
gray_list
=
gray_list
)
if
not
is_debug
:
return
{
"linucb_topic_ids"
:
recommend_topic_ids
,
"rank_topic_ids"
:
rank_topic_ids
,
"useful_topic_ids"
:
useful_topic_ids
,
"linucb_pictorial_ids"
:
recommend_pictorial_ids
}
...
...
@@ -451,7 +452,7 @@ def home_recommend(device_id="", user_id=-1, offset=0, lin_pictorial_count=4, si
"debug_model_data"
:
results
}
else
:
recommend_pictorial_ids
=
get_home_recommend_pictorial_ids
(
user_id
,
device_id
,
lin_pictorial_count
,
is_gray
=
is_gray
)
recommend_pictorial_ids
=
get_home_recommend_pictorial_ids
(
user_id
,
device_id
,
lin_pictorial_count
,
gray_list
=
gray_list
)
size
=
size
-
len
(
recommend_pictorial_ids
)
if
is_debug
:
has_score
=
True
...
...
@@ -462,7 +463,7 @@ def home_recommend(device_id="", user_id=-1, offset=0, lin_pictorial_count=4, si
size
=
size
,
query_type
=
query_type
,
promote_topic_list
=
promote_topic_list
,
has_score
=
has_score
,
is_gray
=
is_gray
)
has_score
=
has_score
,
gray_list
=
gray_list
)
else
:
has_score
=
False
...
...
@@ -470,7 +471,7 @@ def home_recommend(device_id="", user_id=-1, offset=0, lin_pictorial_count=4, si
offset
=
0
,
size
=
size
,
query_type
=
query_type
,
promote_topic_list
=
promote_topic_list
,
has_score
=
has_score
,
is_gray
=
is_gray
)
has_score
=
has_score
,
gray_list
=
gray_list
)
if
not
is_debug
:
return
{
"linucb_topic_ids"
:
recommend_topic_ids
,
"rank_topic_ids"
:
rank_topic_ids
,
...
...
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