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
76379c4c
Commit
76379c4c
authored
Apr 17, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add es_type attention_user_tag
parent
4bd61032
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
2 deletions
+39
-2
tasks.py
injection/data_sync/tasks.py
+2
-0
register_user_tag.py
linucb/utils/register_user_tag.py
+37
-2
No files found.
injection/data_sync/tasks.py
View file @
76379c4c
...
@@ -20,6 +20,8 @@ def write_to_es(es_type, pk_list, use_batch_query_set=False):
...
@@ -20,6 +20,8 @@ def write_to_es(es_type, pk_list, use_batch_query_set=False):
if
es_type
==
"register_user_tag"
:
if
es_type
==
"register_user_tag"
:
RegisterUserTag
.
get_register_user_tag
(
pk_list
)
RegisterUserTag
.
get_register_user_tag
(
pk_list
)
elif
es_type
==
"attention_user_tag"
:
RegisterUserTag
.
get_user_attention_tag
(
pk_list
)
else
:
else
:
type_info_map
=
get_type_info_map
()
type_info_map
=
get_type_info_map
()
type_info
=
type_info_map
[
es_type
]
type_info
=
type_info_map
[
es_type
]
...
...
linucb/utils/register_user_tag.py
View file @
76379c4c
...
@@ -9,7 +9,7 @@ import traceback
...
@@ -9,7 +9,7 @@ import traceback
import
json
import
json
import
pickle
import
pickle
from
django.conf
import
settings
from
django.conf
import
settings
from
trans2es.models.tag
import
AccountUserTag
from
trans2es.models.tag
import
AccountUserTag
,
CommunityTagFollow
from
libs.es
import
ESPerform
from
libs.es
import
ESPerform
import
libs.tools
as
Tools
import
libs.tools
as
Tools
from
search.utils.common
import
*
from
search.utils.common
import
*
...
@@ -30,8 +30,40 @@ class RegisterUserTag(object):
...
@@ -30,8 +30,40 @@ class RegisterUserTag(object):
linucb_user_id_register_tag_topic_id_prefix
=
"physical:linucb:register_tag_topic_recommend:user_id:"
linucb_user_id_register_tag_topic_id_prefix
=
"physical:linucb:register_tag_topic_recommend:user_id:"
linucb_register_user_tag_key
=
"physical:linucb:register_user_tag_info"
linucb_register_user_tag_key
=
"physical:linucb:register_user_tag_info"
@classmethod
def
get_user_attention_tag
(
cls
,
pk_list
):
"""
:remark 获取用户关注标签
:param pk_list:
:return:
"""
try
:
user_id_dict
=
dict
()
query_results
=
CommunityTagFollow
.
objects
.
filter
(
pk__in
=
pk_list
,
is_deleted
=
False
,
is_online
=
True
)
for
item
in
query_results
:
tag_id
=
item
.
tag_id
user_id
=
item
.
user_id
user_tag_list
=
CommunityTagFollow
.
objects
.
filter
(
user
=
user_id
,
is_deleted
=
False
,
is_online
=
True
)
.
values_list
(
"tag_id"
,
flat
=
True
)
user_id_dict
[
user_id
]
=
user_tag_list
for
user_id
in
user_id_dict
:
redis_user_tag_id_data
=
redis_client
.
hget
(
cls
.
linucb_register_user_tag_key
,
user_id
)
redis_user_tag_id_list
=
json
.
loads
(
redis_user_tag_id_data
)
if
redis_user_tag_id_data
else
[]
redis_user_tag_id_list
.
extend
(
user_id_dict
[
user_id
])
redis_client
.
hset
(
cls
.
linucb_register_user_tag_key
,
user_id
,
json
.
dumps
(
list
(
set
(
redis_user_tag_id_list
))))
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
@classmethod
@classmethod
def
get_register_user_tag
(
cls
,
pk_list
):
def
get_register_user_tag
(
cls
,
pk_list
):
"""
:remark 用户注册时选的标签
:param pk_list:
:return:
"""
try
:
try
:
# user_id_set = set()
# user_id_set = set()
user_id_dict
=
dict
()
user_id_dict
=
dict
()
...
@@ -43,7 +75,10 @@ class RegisterUserTag(object):
...
@@ -43,7 +75,10 @@ class RegisterUserTag(object):
user_id_dict
[
user_id
]
=
user_tag_list
user_id_dict
[
user_id
]
=
user_tag_list
for
user_id
in
user_id_dict
:
for
user_id
in
user_id_dict
:
redis_client
.
hset
(
cls
.
linucb_register_user_tag_key
,
user_id
,
json
.
dumps
(
list
(
user_id_dict
[
user_id
])))
redis_user_tag_id_data
=
redis_client
.
hget
(
cls
.
linucb_register_user_tag_key
,
user_id
)
redis_user_tag_id_list
=
json
.
loads
(
redis_user_tag_id_data
)
if
redis_user_tag_id_data
else
[]
redis_user_tag_id_list
.
extend
(
user_id_dict
[
user_id
])
redis_client
.
hset
(
cls
.
linucb_register_user_tag_key
,
user_id
,
json
.
dumps
(
list
(
set
(
redis_user_tag_id_list
))))
# if user_id not in user_id_set:
# if user_id not in user_id_set:
# user_id_set.add(user_id)
# user_id_set.add(user_id)
...
...
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