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
08f92bb5
Commit
08f92bb5
authored
Jun 03, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
定时任务
parent
6647a8a6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
9 deletions
+24
-9
tasks.py
injection/data_sync/tasks.py
+20
-0
search_hotword.py
search/views/search_hotword.py
+4
-9
No files found.
injection/data_sync/tasks.py
View file @
08f92bb5
...
...
@@ -15,6 +15,7 @@ from libs.es import ESPerform
from
libs.cache
import
redis_client
from
trans2es.models.face_user_contrast_similar
import
FaceUserContrastSimilar
,
UserSimilarScore
from
linucb.utils.register_user_tag
import
RegisterUserTag
from
trans2es.models.tag
import
RegisterShowTag
,
Tag
@shared_task
...
...
@@ -106,3 +107,22 @@ def sync_user_similar_score():
redis_client
.
set
(
redis_key
,
json
.
dumps
(
item_list
))
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
@shared_task
def
get_tag_count
():
try
:
# 获取搜索推荐热词
results_registr_tag
=
RegisterShowTag
.
objects
.
filter
(
is_deleted
=
False
,
is_online
=
1
)
.
count
()
# 获取符合条件的核心词
results_tag
=
Tag
.
objects
.
filter
(
is_online
=
True
,
collection
=
1
)
.
count
()
redis_registr_tag
=
"physical:search_hotword:results_registr_tag"
redis_tag
=
"physical:search_hotword:results_tag"
redis_client
.
set
(
redis_registr_tag
,
str
(
results_registr_tag
))
redis_client
.
set
(
redis_tag
,
str
(
results_tag
))
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
search/views/search_hotword.py
View file @
08f92bb5
...
...
@@ -4,6 +4,7 @@
from
gm_rpcd.all
import
bind
import
logging
import
traceback
import
random
import
json
from
libs.cache
import
redis_client
from
libs.es
import
ESPerform
...
...
@@ -12,7 +13,7 @@ from search.utils.common import GroupSortTypes
from
libs.es
import
ESPerform
from
trans2es.models.pictorial
import
PictorialTopics
from
trans2es.models.tag
import
RegisterShowTag
,
Tag
import
random
from
libs.cache
import
redis_client
@bind
(
"physical/search/search_hotword"
)
...
...
@@ -32,14 +33,8 @@ def search_hotword(device_id=-1):
"""
try
:
all_tag_name_list
=
set
()
# 获取搜索推荐热词
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_registr_tag = 25
results_tag
=
10189849
results_registr_tag
=
int
(
redis_client
.
get
(
"physical:search_hotword:results_registr_tag"
))
results_tag
=
int
(
redis_client
.
get
(
"physical:search_hotword:results_tag"
))
tag_id
=
random
.
sample
(
range
(
1
,
results_registr_tag
),
6
)
results_tag_chose
=
Tag
.
objects
.
filter
(
id__in
=
tag_id
)
.
values_list
(
"name"
,
flat
=
True
)
for
i
in
results_tag_chose
:
...
...
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