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
c2d4d186
Commit
c2d4d186
authored
Apr 19, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify celery bug
parent
9e9779ab
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
50 deletions
+19
-50
register_user_tag.py
linucb/utils/register_user_tag.py
+19
-50
No files found.
linucb/utils/register_user_tag.py
View file @
c2d4d186
...
@@ -29,8 +29,12 @@ class RegisterUserTag(object):
...
@@ -29,8 +29,12 @@ class RegisterUserTag(object):
linucb_device_id_register_tag_topic_id_prefix
=
"physical:linucb:register_tag_topic_recommend:device_id:"
linucb_device_id_register_tag_topic_id_prefix
=
"physical:linucb:register_tag_topic_recommend:device_id:"
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"
# # 用户关注标签
# linucb_user_attention_tag_key = "physical:linucb:user_attention_tag_info"
# # 用户喜好标签(注册勾选 + 关注)
# linucb_user_like_tag_key = "physical:linucb:user_like_tag_info"
@classmethod
@classmethod
def
get_user_attention_tag
(
cls
,
pk_list
):
def
get_user_attention_tag
(
cls
,
pk_list
):
"""
"""
...
@@ -48,11 +52,14 @@ class RegisterUserTag(object):
...
@@ -48,11 +52,14 @@ class RegisterUserTag(object):
user_tag_list
=
CommunityTagFollow
.
objects
.
filter
(
user_id
=
user_id
,
is_deleted
=
False
,
is_online
=
True
)
.
values_list
(
"tag_id"
,
flat
=
True
)
user_tag_list
=
CommunityTagFollow
.
objects
.
filter
(
user_id
=
user_id
,
is_deleted
=
False
,
is_online
=
True
)
.
values_list
(
"tag_id"
,
flat
=
True
)
user_id_dict
[
user_id
]
=
user_tag_list
user_id_dict
[
user_id
]
=
user_tag_list
user_register_tag_list
=
AccountUserTag
.
objects
.
filter
(
user
=
user_id
,
is_deleted
=
False
)
.
values_list
(
"tag_id"
,
flat
=
True
)
user_id_dict
[
user_id
]
.
extend
(
user_register_tag_list
)
for
user_id
in
user_id_dict
:
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_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 = 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_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
))))
redis_client
.
hset
(
cls
.
linucb_register_user_tag_key
,
user_id
,
json
.
dumps
(
list
(
set
(
user_id_dict
[
user_id
]
))))
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
...
@@ -65,7 +72,6 @@ class RegisterUserTag(object):
...
@@ -65,7 +72,6 @@ class RegisterUserTag(object):
:return:
:return:
"""
"""
try
:
try
:
# user_id_set = set()
user_id_dict
=
dict
()
user_id_dict
=
dict
()
query_results
=
AccountUserTag
.
objects
.
filter
(
pk__in
=
pk_list
)
query_results
=
AccountUserTag
.
objects
.
filter
(
pk__in
=
pk_list
)
for
item
in
query_results
:
for
item
in
query_results
:
...
@@ -74,51 +80,14 @@ class RegisterUserTag(object):
...
@@ -74,51 +80,14 @@ class RegisterUserTag(object):
user_tag_list
=
AccountUserTag
.
objects
.
filter
(
user
=
user_id
)
.
values_list
(
"tag_id"
,
flat
=
True
)
user_tag_list
=
AccountUserTag
.
objects
.
filter
(
user
=
user_id
)
.
values_list
(
"tag_id"
,
flat
=
True
)
user_id_dict
[
user_id
]
=
user_tag_list
user_id_dict
[
user_id
]
=
user_tag_list
user_follow_tag_list
=
CommunityTagFollow
.
objects
.
filter
(
user_id
=
user_id
,
is_deleted
=
False
,
is_online
=
True
)
.
values_list
(
"tag_id"
,
flat
=
True
)
user_id_dict
[
user_id
]
.
extend
(
user_follow_tag_list
)
for
user_id
in
user_id_dict
:
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_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 = 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_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
))))
redis_client
.
hset
(
cls
.
linucb_register_user_tag_key
,
user_id
,
json
.
dumps
(
list
(
set
(
user_id_dict
[
user_id
]
))))
# if user_id not in user_id_set:
# user_id_set.add(user_id)
#
# user_tag_list = AccountUserTag.objects.filter(user=user_id).values_list("tag_id",flat=True)
#
# have_read_topic_id_list = Tools.get_have_read_topic_id_list(-1, user_id,
# TopicPageType.HOME_RECOMMEND)
# recommend_topic_id_list = list()
# cycle_num = int(10000/len(user_tag_list))
# for index in range(0,cycle_num):
# for tag_id in user_tag_list:
# redis_tag_id_key = cls.tag_topic_id_redis_prefix + str(tag_id)
# redis_tag_id_data = redis_client.get(redis_tag_id_key)
# tag_topic_id_list = json.loads(redis_tag_id_data) if redis_tag_id_data else []
# if not redis_tag_id_data:
# tag_topic_id_list = ESPerform.get_tag_topic_list(tag_id)
# redis_client.set(redis_tag_id_key,json.dumps(tag_topic_id_list))
# redis_client.expire(redis_tag_id_key,1*24*60*60)
#
# if len(tag_topic_id_list)>index:
# for topic_id in tag_topic_id_list[index:]:
# if topic_id not in have_read_topic_id_list and topic_id not in recommend_topic_id_list:
# recommend_topic_id_list.append(topic_id)
# break
#
# redis_register_tag_topic_data = {
# "data": json.dumps(recommend_topic_id_list),
# "cursor": 0
# }
# redis_client.hmset(cls.linucb_user_id_register_tag_topic_id_prefix,redis_register_tag_topic_data)
# redis_client.expire(cls.linucb_user_id_register_tag_topic_id_prefix,30*24*60*60)
#
# topic_recommend_redis_key = cls.linucb_user_id_recommend_topic_id_prefix + str(user_id)
# redis_data_dict = {
# "data": json.dumps(recommend_topic_id_list),
# "cursor":0
# }
# redis_client.hmset(topic_recommend_redis_key,redis_data_dict)
# redis_client.expire(topic_recommend_redis_key,30*24*60*60)
#
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
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