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
2ff62ef8
Commit
2ff62ef8
authored
Mar 08, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
3e97dfff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
3 deletions
+27
-3
tasks.py
injection/data_sync/tasks.py
+23
-0
topic.py
search/utils/topic.py
+4
-3
No files found.
injection/data_sync/tasks.py
View file @
2ff62ef8
...
...
@@ -62,3 +62,26 @@ def sync_face_similar_data_to_redis():
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
@shared_task
def
sync_user_similar_score
():
try
:
results_items
=
UserSimilarScore
.
objects
.
filter
(
is_deleted
=
False
)
.
distinct
()
.
values
(
"user_id"
)
.
values_list
(
flat
=
True
)
redis_key_prefix
=
"physical:user_similar_score:user_id:"
logging
.
info
(
"duan add,begin sync user_similar_score!"
)
for
user_id
in
results_items
:
redis_key
=
redis_key_prefix
+
str
(
user_id
)
similar_results_items
=
UserSimilarScore
.
objects
.
filter
(
is_deleted
=
False
,
user_id
=
user_id
)
.
order_by
(
"-score"
)
item_list
=
list
()
for
item
in
similar_results_items
:
contrast_user_id
=
item
.
contrast_user_id
score
=
item
.
score
item_list
.
append
(
[
contrast_user_id
,
score
]
)
redis_client
.
set
(
redis_key
,
json
.
dumps
(
item_list
))
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
search/utils/topic.py
View file @
2ff62ef8
...
...
@@ -146,7 +146,7 @@ class TopicUtils(object):
same_group_user_info_list
=
result_dict
[
"hits"
][
0
][
"_source"
][
"same_group_user_id_list"
]
same_group_id_list
=
[
item
[
"user_id"
]
for
item
in
same_group_user_info_list
]
same_group_id_list
=
same_group_id_list
[:
100
0
]
same_group_id_list
=
same_group_id_list
[:
100
]
user_tag_list
=
result_dict
[
"hits"
][
0
][
"_source"
][
"tag_list"
]
...
...
@@ -178,12 +178,13 @@ class TopicUtils(object):
]
if
len
(
user_similar_score_list
)
>
0
:
for
item
in
user_similar_score_list
:
for
item
in
user_similar_score_list
[:
100
]:
score_item
=
3
*
10
*
item
[
1
]
functions_list
.
append
(
{
"filter"
:
{
"bool"
:
{
"should"
:
{
"term"
:
{
"user_id"
:
item
[
0
]}}}},
"weight"
:
3
*
10
*
item
[
1
]
,
"weight"
:
score_item
,
}
)
...
...
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