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
3e97dfff
Commit
3e97dfff
authored
Mar 07, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify bug
parent
03cb75fd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
13 deletions
+35
-13
tasks.py
injection/data_sync/tasks.py
+2
-1
topic.py
search/utils/topic.py
+12
-11
topic.py
search/views/topic.py
+5
-1
face_user_contrast_similar.py
trans2es/models/face_user_contrast_similar.py
+16
-0
No files found.
injection/data_sync/tasks.py
View file @
3e97dfff
...
@@ -9,7 +9,7 @@ from libs.es import ESPerform
...
@@ -9,7 +9,7 @@ from libs.es import ESPerform
import
logging
import
logging
import
traceback
import
traceback
from
libs.cache
import
redis_client
from
libs.cache
import
redis_client
from
trans2es.models.face_user_contrast_similar
import
FaceUserContrastSimilar
from
trans2es.models.face_user_contrast_similar
import
FaceUserContrastSimilar
,
UserSimilarScore
import
json
import
json
...
@@ -61,3 +61,4 @@ def sync_face_similar_data_to_redis():
...
@@ -61,3 +61,4 @@ def sync_face_similar_data_to_redis():
logging
.
info
(
"duan add,participant_user_id:
%
d set data done!"
%
participant_user_id
)
logging
.
info
(
"duan add,participant_user_id:
%
d set data done!"
%
participant_user_id
)
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
search/utils/topic.py
View file @
3e97dfff
...
@@ -118,7 +118,7 @@ class TopicUtils(object):
...
@@ -118,7 +118,7 @@ class TopicUtils(object):
return
{}
return
{}
@classmethod
@classmethod
def
get_recommend_topic_ids
(
cls
,
user_id
,
offset
,
size
,
query
=
None
,
query_type
=
TopicPageType
.
FIND_PAGE
,
filter_topic_id_list
=
[],
test_score
=
False
,
must_topic_id_list
=
[],
recommend_tag_list
=
[]):
def
get_recommend_topic_ids
(
cls
,
user_id
,
offset
,
size
,
query
=
None
,
query_type
=
TopicPageType
.
FIND_PAGE
,
filter_topic_id_list
=
[],
test_score
=
False
,
must_topic_id_list
=
[],
recommend_tag_list
=
[]
,
user_similar_score_list
=
[]
):
"""
"""
:需增加打散逻辑
:需增加打散逻辑
:remark:获取首页推荐帖子列表
:remark:获取首页推荐帖子列表
...
@@ -167,7 +167,7 @@ class TopicUtils(object):
...
@@ -167,7 +167,7 @@ class TopicUtils(object):
"weight"
:
3
"weight"
:
3
},
},
{
{
"
gauss
"
:
{
"
linear
"
:
{
"create_time"
:
{
"create_time"
:
{
"scale"
:
"1d"
,
"scale"
:
"1d"
,
"decay"
:
0.99
"decay"
:
0.99
...
@@ -175,17 +175,18 @@ class TopicUtils(object):
...
@@ -175,17 +175,18 @@ class TopicUtils(object):
},
},
"weight"
:
500
"weight"
:
500
}
}
# {
# "gauss": {
# "create_time": {
# "scale": "1d",
# "decay": 0.9
# }
# },
# "weight": 10
# }
]
]
if
len
(
user_similar_score_list
)
>
0
:
for
item
in
user_similar_score_list
:
functions_list
.
append
(
{
"filter"
:
{
"bool"
:
{
"should"
:
{
"term"
:
{
"user_id"
:
item
[
0
]}}}},
"weight"
:
3
*
10
*
item
[
1
],
}
)
if
len
(
attention_user_id_list
)
>
0
:
if
len
(
attention_user_id_list
)
>
0
:
functions_list
.
append
(
functions_list
.
append
(
{
{
...
...
search/views/topic.py
View file @
3e97dfff
...
@@ -71,7 +71,11 @@ def get_home_recommend_topic_ids(user_id,device_id,offset,size,query=None,query_
...
@@ -71,7 +71,11 @@ def get_home_recommend_topic_ids(user_id,device_id,offset,size,query=None,query_
if
redis_field_val_list
[
0
]:
if
redis_field_val_list
[
0
]:
have_read_topic_id_list
=
list
(
json
.
loads
(
redis_field_val_list
[
0
]))
have_read_topic_id_list
=
list
(
json
.
loads
(
redis_field_val_list
[
0
]))
topic_id_dict
=
TopicUtils
.
get_recommend_topic_ids
(
user_id
,
offset
,
size
*
size
,
query
,
query_type
,
filter_topic_id_list
=
have_read_topic_id_list
,
recommend_tag_list
=
recommend_tag_list
)
user_similar_score_redis_key
=
"physical:user_similar_score:user_id:"
+
str
(
user_id
)
redis_user_similar_score_redis_val
=
redis_client
.
get
(
user_similar_score_redis_key
)
user_similar_score_redis_list
=
json
.
loads
(
redis_user_similar_score_redis_val
)
if
redis_user_similar_score_redis_val
else
[]
topic_id_dict
=
TopicUtils
.
get_recommend_topic_ids
(
user_id
,
offset
,
size
*
size
,
query
,
query_type
,
filter_topic_id_list
=
have_read_topic_id_list
,
recommend_tag_list
=
recommend_tag_list
,
user_similar_score_list
=
user_similar_score_redis_list
)
have_read_group_id_set
=
set
()
have_read_group_id_set
=
set
()
have_read_user_id_set
=
set
()
have_read_user_id_set
=
set
()
unread_topic_id_dict
=
dict
()
unread_topic_id_dict
=
dict
()
...
...
trans2es/models/face_user_contrast_similar.py
View file @
3e97dfff
...
@@ -25,3 +25,19 @@ class FaceUserContrastSimilar(models.Model):
...
@@ -25,3 +25,19 @@ class FaceUserContrastSimilar(models.Model):
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
contrast_user_id
=
models
.
IntegerField
(
verbose_name
=
u'对照者用户ID'
)
contrast_user_id
=
models
.
IntegerField
(
verbose_name
=
u'对照者用户ID'
)
class
UserSimilarScore
(
models
.
Model
):
class
Meta
:
verbose_name
=
u"首页推荐用"
db_table
=
"user_similar_score"
id
=
models
.
IntegerField
(
verbose_name
=
u"主键ID"
,
db_index
=
True
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u"是否删除"
)
user_id
=
models
.
IntegerField
(
verbose_name
=
u"用户ID"
)
contrast_user_id
=
models
.
BigIntegerField
(
verbose_name
=
"参数对比的用户id"
,
db_index
=
True
)
score
=
models
.
FloatField
(
verbose_name
=
'相似度'
,
default
=
0
)
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
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