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
223b7f36
Commit
223b7f36
authored
Mar 26, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git.wanmeizhensuo.com:alpha/physical
parents
3ebbedb3
47724ec7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
20 deletions
+53
-20
topic.py
search/views/topic.py
+2
-2
user.py
trans2es/models/user.py
+37
-14
user_transfer.py
trans2es/utils/user_transfer.py
+14
-4
No files found.
search/views/topic.py
View file @
223b7f36
...
@@ -247,7 +247,7 @@ def home_query(device_id="", tag_id=-1, user_id=-1, query="", offset=0, size=10)
...
@@ -247,7 +247,7 @@ def home_query(device_id="", tag_id=-1, user_id=-1, query="", offset=0, size=10)
@bind
(
"physical/search/topic_detail_page_recommend"
)
@bind
(
"physical/search/topic_detail_page_recommend"
)
def
topic_detail_page_recommend
(
device_id
=
""
,
user_id
=-
1
,
topic_id
=-
1
,
topic_
group
_id
=-
1
,
topic_user_id
=-
1
,
def
topic_detail_page_recommend
(
device_id
=
""
,
user_id
=-
1
,
topic_id
=-
1
,
topic_
pictorial
_id
=-
1
,
topic_user_id
=-
1
,
filter_topic_user_id
=
False
,
offset
=
0
,
size
=
10
):
filter_topic_user_id
=
False
,
offset
=
0
,
size
=
10
):
"""
"""
:remark:帖子详情页推荐策略,缺少第一个卡片策略
:remark:帖子详情页推荐策略,缺少第一个卡片策略
...
@@ -271,7 +271,7 @@ def topic_detail_page_recommend(device_id="", user_id=-1, topic_id=-1, topic_gro
...
@@ -271,7 +271,7 @@ def topic_detail_page_recommend(device_id="", user_id=-1, topic_id=-1, topic_gro
# 获取帖子标签列表
# 获取帖子标签列表
topic_tag_list
=
TopicUtils
.
get_topic_tag_id_list
(
topic_id
,
es_cli_obj
)
topic_tag_list
=
TopicUtils
.
get_topic_tag_id_list
(
topic_id
,
es_cli_obj
)
result_list
=
TopicUtils
.
get_topic_detail_recommend_list
(
user_id
,
topic_id
,
topic_tag_list
,
topic_
group
_id
,
result_list
=
TopicUtils
.
get_topic_detail_recommend_list
(
user_id
,
topic_id
,
topic_tag_list
,
topic_
pictorial
_id
,
topic_user_id
,
filter_topic_user_id
,
topic_user_id
,
filter_topic_user_id
,
have_read_topic_list
,
offset
,
size
,
es_cli_obj
,
index_type
=
"topic-high-star"
)
have_read_topic_list
,
offset
,
size
,
es_cli_obj
,
index_type
=
"topic-high-star"
)
recommend_topic_ids_list
=
list
()
recommend_topic_ids_list
=
list
()
...
...
trans2es/models/user.py
View file @
223b7f36
...
@@ -15,7 +15,7 @@ from .group_user_role import GroupUserRole
...
@@ -15,7 +15,7 @@ from .group_user_role import GroupUserRole
from
.tag
import
AccountUserTag
from
.tag
import
AccountUserTag
from
.topic
import
Topic
from
.topic
import
Topic
from
.user_extra
import
UserExtra
from
.user_extra
import
UserExtra
from
.pictorial
import
PictorialFollow
class
User
(
models
.
Model
):
class
User
(
models
.
Model
):
class
Meta
:
class
Meta
:
...
@@ -91,6 +91,26 @@ class User(models.Model):
...
@@ -91,6 +91,26 @@ class User(models.Model):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
return
[]
def
get_attention_pictorial_id_list
(
self
):
try
:
attention_pictorial_id_list
=
list
()
query_results
=
PictorialFollow
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
is_online
=
True
,
user_id
=
self
.
user_id
)
logging
.
info
(
"get PictorialFollow:
%
s"
%
query_results
)
for
item
in
query_results
:
item_dict
=
{
"pictorial_id"
:
item
.
pictorial_id
,
"update_time_val"
:
time
.
mktime
(
tzlc
(
item
.
update_time
)
.
timetuple
())
}
attention_pictorial_id_list
.
append
(
item_dict
)
logging
.
info
(
"get user_id:
%
s"
%
self
.
user_id
)
logging
.
info
(
"get same_pictorial_user_id_list:
%
s"
%
attention_pictorial_id_list
)
return
attention_pictorial_id_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
def
get_pick_user_id_list
(
self
):
def
get_pick_user_id_list
(
self
):
pick_topic_id_list
=
list
()
pick_topic_id_list
=
list
()
user_picks
=
self
.
user_pick
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
is_deleted
=
False
,
is_pick
=
True
)
user_picks
=
self
.
user_pick
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
is_deleted
=
False
,
is_pick
=
True
)
...
@@ -117,32 +137,35 @@ class User(models.Model):
...
@@ -117,32 +137,35 @@ class User(models.Model):
return
pick_user_detail_list
return
pick_user_detail_list
def
get_same_
group
_user_id_list
(
self
):
def
get_same_
pictorial
_user_id_list
(
self
):
#todo 有的同组数据过大,导致celery cpu过高,暂时限制同组的数据大小,后续可能会去掉同组的数据
#todo 有的同组数据过大,导致celery cpu过高,暂时限制同组的数据大小,后续可能会去掉同组的数据
same_
group
_user_id_list
=
list
()
same_
pictorial
_user_id_list
=
list
()
group_items_list
=
list
(
GroupUserRole
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id
=
self
.
user_id
)
.
values_list
(
"group
_id"
,
flat
=
True
))
pictorial_items_list
=
list
(
PictorialFollow
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id
=
self
.
user_id
)
.
values_list
(
"pictorial
_id"
,
flat
=
True
))
for
group_id
in
group
_items_list
:
for
pictorial_id
in
pictorial
_items_list
:
user_items_list
=
list
(
GroupUserRole
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
group_id
=
group
_id
)
.
values_list
(
"user_id"
,
flat
=
True
))
user_items_list
=
list
(
PictorialFollow
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
pictorial_id
=
pictorial
_id
)
.
values_list
(
"user_id"
,
flat
=
True
))
for
user_id
in
user_items_list
:
for
user_id
in
user_items_list
:
same_
group
_user_id_list
.
append
(
user_id
)
same_
pictorial
_user_id_list
.
append
(
user_id
)
if
len
(
same_
group
_user_id_list
)
>=
100
:
if
len
(
same_
pictorial
_user_id_list
)
>=
100
:
break
break
if
len
(
same_
group
_user_id_list
)
>=
100
:
if
len
(
same_
pictorial
_user_id_list
)
>=
100
:
break
break
logging
.
info
(
"get same user_id:
%
s"
%
self
.
user_id
)
logging
.
info
(
"get same_pictorial_user_id_list:
%
s"
%
same_pictorial_user_id_list
)
same_
group
_detail_list
=
list
()
same_
pictorial
_detail_list
=
list
()
for
i
in
range
(
0
,
len
(
same_
group
_user_id_list
),
200
):
for
i
in
range
(
0
,
len
(
same_
pictorial
_user_id_list
),
200
):
sql_data_list
=
User
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id__in
=
same_
group
_user_id_list
[
i
:
i
+
1000
])
sql_data_list
=
User
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id__in
=
same_
pictorial
_user_id_list
[
i
:
i
+
1000
])
for
detail_data
in
sql_data_list
:
for
detail_data
in
sql_data_list
:
item
=
{
item
=
{
"user_id"
:
detail_data
.
user_id
,
"user_id"
:
detail_data
.
user_id
,
"country_id"
:
detail_data
.
country_id
"country_id"
:
detail_data
.
country_id
}
}
same_
group
_detail_list
.
append
(
item
)
same_
pictorial
_detail_list
.
append
(
item
)
return
same_
group
_detail_list
return
same_
pictorial
_detail_list
def
get_user_tag_id_list
(
self
):
def
get_user_tag_id_list
(
self
):
try
:
try
:
...
...
trans2es/utils/user_transfer.py
View file @
223b7f36
...
@@ -74,16 +74,26 @@ class UserTransfer(object):
...
@@ -74,16 +74,26 @@ class UserTransfer(object):
try
:
try
:
res
[
"tag_list"
]
=
instance
.
get_user_tag_id_list
()
res
[
"tag_list"
]
=
instance
.
get_user_tag_id_list
()
res
[
"attention_user_id_list"
]
=
cls
.
get_follow_user_id_list
(
userInstance
=
instance
)
res
[
"attention_user_id_list"
]
=
cls
.
get_follow_user_id_list
(
userInstance
=
instance
)
res
[
"attention_group_id_list"
]
=
instance
.
get_attention_group_id_list
()
# res["attention_group_id_list"] = instance.get_attention_group_id_list()
res
[
"pick_user_id_list"
]
=
instance
.
get_pick_user_id_list
()
res
[
"pick_user_id_list"
]
=
instance
.
get_pick_user_id_list
()
res
[
"same_group_user_id_list"
]
=
instance
.
get_same_group_user_id_list
()
res
[
"attention_pictorial_id_list"
]
=
instance
.
get_attention_pictorial_id_list
()
# res["same_group_user_id_list"] = instance.get_same_group_user_id_list()
res
[
"same_pictorial_user_id_list"
]
=
instance
.
get_same_pictorial_user_id_list
()
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
res
[
"tag_list"
]
=
[]
res
[
"tag_list"
]
=
[]
res
[
"attention_user_id_list"
]
=
[]
res
[
"attention_user_id_list"
]
=
[]
res
[
"attention_group_id_list"
]
=
[]
#
res["attention_group_id_list"] = []
res
[
"pick_user_id_list"
]
=
[]
res
[
"pick_user_id_list"
]
=
[]
res
[
"same_group_user_id_list"
]
=
[]
# res["same_group_user_id_list"] = []
res
[
"attention_pictorial_id_list"
]
=
[]
res
[
"same_pictorial_user_id_list"
]
=
[]
return
res
return
res
except
:
except
:
...
...
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