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
f90e0b9e
Commit
f90e0b9e
authored
May 29, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
e10b33c3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
14 deletions
+16
-14
app_conf.xml
app_conf.xml
+1
-0
search_hotword.py
search/views/search_hotword.py
+15
-14
topic.py
search/views/topic.py
+0
-0
No files found.
app_conf.xml
View file @
f90e0b9e
...
@@ -17,5 +17,6 @@
...
@@ -17,5 +17,6 @@
<element
value=
"search.views.contrast_similar"
/>
<element
value=
"search.views.contrast_similar"
/>
<element
value=
"injection.data_sync.tasks"
/>
<element
value=
"injection.data_sync.tasks"
/>
<element
value=
"search.views.contrast_similar"
/>
<element
value=
"search.views.contrast_similar"
/>
<element
value=
"search.views.search_hotword"
/>
</config>
</config>
</gm_rpcd_config>
</gm_rpcd_config>
search/views/search_hotword.py
View file @
f90e0b9e
...
@@ -33,36 +33,37 @@ def search_hotword(device_id=-1):
...
@@ -33,36 +33,37 @@ def search_hotword(device_id=-1):
try
:
try
:
all_tag_name_list
=
set
()
all_tag_name_list
=
set
()
# 获取搜索推荐热词
# 获取搜索推荐热词
results_registr_tag
=
RegisterShowTag
.
objects
.
filter
(
is_deleted
=
False
,
is_online
=
1
)
.
count
()
results_registr_tag
=
RegisterShowTag
.
objects
.
filter
(
is_deleted
=
False
,
is_online
=
1
)
.
count
()
results_tag
=
Tag
.
objects
.
filter
(
is_online
=
True
,
collection
=
1
)
.
count
()
results_tag
=
Tag
.
objects
.
filter
(
is_online
=
True
,
collection
=
1
)
.
count
()
for
i
in
range
(
0
,
6
):
tag_id
=
random
.
sample
(
range
(
1
,
results_registr_tag
),
1
)
tag_id
=
random
.
randint
(
0
,
results_registr_tag
)
results_tag_chose
=
Tag
.
objects
.
filter
(
id__in
=
tag_id
)
.
values_list
(
"name"
,
flat
=
True
)
results_tag_chose
=
Tag
.
objects
.
filter
(
id
=
tag_id
)
.
values_list
(
"name"
,
flat
=
True
)
for
i
in
results_tag_chose
:
all_tag_name_list
.
add
(
results_tag_chose
)
all_tag_name_list
.
add
(
i
)
logging
.
info
(
"get all_tag_name_list01:
%
s"
%
all_tag_name_list
)
# 获取个性化标签
# 获取个性化标签
linucb_recommend_redis_prefix
=
"physical:linucb:tag_recommend:device_id:"
linucb_recommend_redis_prefix
=
"physical:linucb:tag_recommend:device_id:"
tag_recommend_redis_key
=
linucb_recommend_redis_prefix
+
str
(
device_id
)
tag_recommend_redis_key
=
linucb_recommend_redis_prefix
+
str
(
device_id
)
linucb_recommend_tag_data
=
redis_client
.
get
(
tag_recommend_redis_key
)
linucb_recommend_tag_data
=
redis_client
.
get
(
tag_recommend_redis_key
)
linucb_recommend_tag_list
=
json
.
loads
(
linucb_recommend_tag_data
)
if
linucb_recommend_tag_data
else
[]
linucb_recommend_tag_list
=
json
.
loads
(
linucb_recommend_tag_data
)
if
linucb_recommend_tag_data
else
[]
for
item
in
linucb_recommend_tag_list
:
for
item
in
linucb_recommend_tag_list
:
all_tag_name_list
.
add
(
item
)
results_tag_recommend
=
Tag
.
objects
.
filter
(
id
=
item
,
is_online
=
True
)
.
values_list
(
"name"
,
flat
=
True
)
all_tag_name_list
.
add
(
results_tag_recommend
[
0
])
if
len
(
all_tag_name_list
)
==
12
:
return
{
"recommend_tag_name"
:
list
(
all_tag_name_list
)}
logging
.
info
(
"get all_tag_name_list02:
%
s"
%
all_tag_name_list
)
logging
.
info
(
"get all_tag_name_list02:
%
s"
%
all_tag_name_list
)
# 取不够数则取核心标签
# 取不够数则取核心标签
if
len
(
all_tag_name_list
)
<
12
:
if
len
(
all_tag_name_list
)
<
12
:
for
i
in
range
(
0
,
12
):
for
i
in
range
(
0
,
12
):
tag_id
=
random
.
randint
(
0
,
results_tag
)
tag_id
=
random
.
sample
(
range
(
1
,
results_tag
),
12
-
len
(
all_tag_name_list
)
)
results_tag_hexin
=
Tag
.
objects
.
filter
(
id
=
tag_id
)
.
values_list
(
"name"
,
flat
=
True
)
results_tag_hexin
=
Tag
.
objects
.
filter
(
id
__in
=
tag_id
)
.
values_list
(
"name"
,
flat
=
True
)
if
results_tag_hexin
not
in
all_tag_name_list
:
if
results_tag_hexin
not
in
all_tag_name_list
:
all_tag_name_list
.
add
(
results_tag_hexin
)
all_tag_name_list
.
add
(
results_tag_hexin
[
0
]
)
if
len
(
all_tag_name_list
)
>=
12
:
if
len
(
all_tag_name_list
)
>=
12
:
logging
.
info
(
"get all_tag_name_list03:
%
s"
%
all_tag_name_list
)
return
{
"recommend_tag_name"
:
list
(
all_tag_name_list
)}
return
{
"recommend_name"
:
all_tag_name_list
}
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
"recommend_name"
:
[]}
return
{
"recommend_
tag_
name"
:
[]}
search/views/topic.py
View file @
f90e0b9e
This diff is collapsed.
Click to expand it.
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