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
85d71bf0
Commit
85d71bf0
authored
Mar 13, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'similar_sort' into 'master'
Similar sort See merge request
!164
parents
09f9349e
20441121
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
22 deletions
+22
-22
topic.py
search/views/topic.py
+1
-1
celebrity.py
trans2es/models/celebrity.py
+1
-1
topic.py
trans2es/models/topic.py
+9
-9
user.py
trans2es/models/user.py
+11
-11
No files found.
search/views/topic.py
View file @
85d71bf0
...
...
@@ -68,7 +68,7 @@ def get_home_recommend_topic_ids(user_id,device_id,offset,size,query=None,query_
recommend_topic_ids
=
[]
have_read_topic_id_list
=
list
()
if
redis_field_val_list
[
0
]:
if
redis_field_val_list
[
0
]
and
query
is
None
:
have_read_topic_id_list
=
list
(
json
.
loads
(
redis_field_val_list
[
0
]))
user_similar_score_redis_key
=
"physical:user_similar_score:user_id:"
+
str
(
user_id
)
...
...
trans2es/models/celebrity.py
View file @
85d71bf0
...
...
@@ -30,7 +30,7 @@ class Celebrity(models.Model):
def
get_pick_id_list
(
self
):
try
:
pick_id_list
=
list
()
query_results
=
PickCelebrity
.
objects
.
filter
(
celebrity_id
=
self
.
id
,
is_deleted
=
False
)
query_results
=
PickCelebrity
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
celebrity_id
=
self
.
id
,
is_deleted
=
False
)
for
data_item
in
query_results
:
pick_id_list
.
append
(
data_item
.
pick_id
)
...
...
trans2es/models/topic.py
View file @
85d71bf0
...
...
@@ -74,7 +74,7 @@ class Topic(models.Model):
try
:
has_image
=
False
query_list
=
TopicImage
.
objects
.
filter
(
topic_id
=
self
.
id
,
is_deleted
=
False
,
is_online
=
True
)
query_list
=
TopicImage
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
topic_id
=
self
.
id
,
is_deleted
=
False
,
is_online
=
True
)
if
len
(
query_list
)
>
0
:
has_image
=
True
...
...
@@ -86,7 +86,7 @@ class Topic(models.Model):
def
get_pick_id_info
(
self
):
try
:
pick_id_list
=
list
()
query_list
=
PickTopic
.
objects
.
filter
(
topic_id
=
self
.
id
,
is_deleted
=
False
)
query_list
=
PickTopic
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
topic_id
=
self
.
id
,
is_deleted
=
False
)
for
item
in
query_list
:
pick_id_list
.
append
(
item
.
pick_id
)
...
...
@@ -100,8 +100,8 @@ class Topic(models.Model):
topic_tag_id_list
=
list
()
edit_tag_id_list
=
list
()
tag_id_list
=
TopicTag
.
objects
.
filter
(
topic_id
=
self
.
id
)
.
values_list
(
"tag_id"
,
flat
=
True
)
tag_query_results
=
Tag
.
objects
.
filter
(
id__in
=
tag_id_list
)
tag_id_list
=
TopicTag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
topic_id
=
self
.
id
)
.
values_list
(
"tag_id"
,
flat
=
True
)
tag_query_results
=
Tag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
id__in
=
tag_id_list
)
for
tag_item
in
tag_query_results
:
is_online
=
tag_item
.
is_online
is_deleted
=
tag_item
.
is_deleted
...
...
@@ -122,7 +122,7 @@ class Topic(models.Model):
tag_name_list
=
list
()
logging
.
info
(
"get tag_id_list :
%
s"
%
tag_id_list
)
for
i
in
range
(
0
,
len
(
tag_name_list
),
1000
):
query_results
=
Tag
.
objects
.
filter
(
id__in
=
tag_id_list
[
i
:
i
+
1000
])
query_results
=
Tag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
id__in
=
tag_id_list
[
i
:
i
+
1000
])
for
item
in
query_results
:
tag_name_list
.
append
(
item
)
return
tag_name_list
...
...
@@ -136,7 +136,7 @@ class Topic(models.Model):
user_is_shadow
=
False
# 是否官方推荐用户
user_query_results
=
UserExtra
.
objects
.
filter
(
user_id
=
self
.
user_id
)
user_query_results
=
UserExtra
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id
=
self
.
user_id
)
if
user_query_results
.
count
()
>
0
:
if
user_query_results
[
0
]
.
is_recommend
:
offline_score
+=
2.0
...
...
@@ -155,9 +155,9 @@ class Topic(models.Model):
elif
self
.
content_level
==
'3'
:
offline_score
+=
2.0
exposure_count
=
ActionSumAboutTopic
.
objects
.
filter
(
topic_id
=
self
.
id
,
data_type
=
1
)
.
count
()
click_count
=
ActionSumAboutTopic
.
objects
.
filter
(
topic_id
=
self
.
id
,
data_type
=
2
)
.
count
()
uv_num
=
ActionSumAboutTopic
.
objects
.
filter
(
topic_id
=
self
.
id
,
data_type
=
3
)
.
count
()
exposure_count
=
ActionSumAboutTopic
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
topic_id
=
self
.
id
,
data_type
=
1
)
.
count
()
click_count
=
ActionSumAboutTopic
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
topic_id
=
self
.
id
,
data_type
=
2
)
.
count
()
uv_num
=
ActionSumAboutTopic
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
topic_id
=
self
.
id
,
data_type
=
3
)
.
count
()
if
exposure_count
>
0
:
offline_score
+=
click_count
/
exposure_count
...
...
trans2es/models/user.py
View file @
85d71bf0
...
...
@@ -37,7 +37,7 @@ class User(models.Model):
def
get_is_recommend_flag
(
self
):
is_shadow
=
False
is_recommend
=
False
query_sql
=
UserExtra
.
objects
.
filter
(
user_id
=
self
.
user_id
,
is_deleted
=
False
,
is_online
=
True
)
query_sql
=
UserExtra
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id
=
self
.
user_id
,
is_deleted
=
False
,
is_online
=
True
)
for
record
in
query_sql
:
is_recommend
=
record
.
is_recommend
is_shadow
=
record
.
is_shadow
...
...
@@ -48,7 +48,7 @@ class User(models.Model):
latest_topic_time_val
=
-
1
# 获取该用户最新发帖时间
topic_records
=
Topic
.
objects
.
filter
(
user_id
=
self
.
user_id
)
.
order_by
(
"-update_time"
)
.
values_list
(
"update_time"
,
topic_records
=
Topic
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id
=
self
.
user_id
)
.
order_by
(
"-update_time"
)
.
values_list
(
"update_time"
,
flat
=
True
)
.
first
()
if
topic_records
:
tzlc_topic_update_time
=
tzlc
(
topic_records
)
...
...
@@ -65,7 +65,7 @@ class User(models.Model):
logging
.
info
(
"get follow_user_id_list :
%
s"
%
follow_user_id_list
)
for
i
in
range
(
0
,
len
(
follow_user_id_list
),
1000
):
logging
.
info
(
"get follow_user_id_list :
%
s"
%
follow_user_id_list
[
i
:
i
+
1000
])
sql_data_list
=
User
.
objects
.
filter
(
user_id__in
=
follow_user_id_list
[
i
:
i
+
1000
])
sql_data_list
=
User
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id__in
=
follow_user_id_list
[
i
:
i
+
1000
])
for
detail_data
in
sql_data_list
:
item
=
{
"user_id"
:
detail_data
.
user_id
,
...
...
@@ -78,7 +78,7 @@ class User(models.Model):
def
get_attention_group_id_list
(
self
):
try
:
attention_group_id_list
=
list
()
query_results
=
GroupUserRole
.
objects
.
filter
(
is_online
=
True
,
user_id
=
self
.
user_id
)
query_results
=
GroupUserRole
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
is_online
=
True
,
user_id
=
self
.
user_id
)
for
item
in
query_results
:
item_dict
=
{
"group_id"
:
item
.
group_id
,
...
...
@@ -93,13 +93,13 @@ class User(models.Model):
def
get_pick_user_id_list
(
self
):
pick_topic_id_list
=
list
()
user_picks
=
self
.
user_pick
.
filter
(
is_deleted
=
False
,
is_pick
=
True
)
user_picks
=
self
.
user_pick
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
is_deleted
=
False
,
is_pick
=
True
)
for
user_pick
in
user_picks
:
pick_topic_id_list
.
append
(
user_pick
.
picktopic_id
)
pick_user_id_list
=
[]
for
i
in
range
(
0
,
len
(
pick_topic_id_list
),
1000
):
topic_sql_list
=
Topic
.
objects
.
filter
(
id__in
=
pick_topic_id_list
[
i
:
i
+
1000
])
topic_sql_list
=
Topic
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
id__in
=
pick_topic_id_list
[
i
:
i
+
1000
])
for
topic_data
in
topic_sql_list
:
pick_user_id_list
.
append
(
topic_data
.
user_id
)
...
...
@@ -107,7 +107,7 @@ class User(models.Model):
pick_user_detail_list
=
list
()
for
i
in
range
(
0
,
len
(
pick_user_id_list
),
1000
):
sql_data_list
=
User
.
objects
.
filter
(
user_id__in
=
pick_user_id_list
[
i
:
i
+
1000
])
sql_data_list
=
User
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id__in
=
pick_user_id_list
[
i
:
i
+
1000
])
for
detail_data
in
sql_data_list
:
item
=
{
"user_id"
:
detail_data
.
user_id
,
...
...
@@ -119,16 +119,16 @@ class User(models.Model):
def
get_same_group_user_id_list
(
self
):
same_group_user_id_list
=
list
()
group_items_list
=
GroupUserRole
.
objects
.
filter
(
user_id
=
self
.
user_id
)
group_items_list
=
GroupUserRole
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id
=
self
.
user_id
)
for
group_item
in
group_items_list
:
group_id
=
group_item
.
group_id
user_items_list
=
GroupUserRole
.
objects
.
filter
(
group_id
=
group_id
)
user_items_list
=
GroupUserRole
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
group_id
=
group_id
)
for
user_items_list
in
user_items_list
:
same_group_user_id_list
.
append
(
user_items_list
.
user_id
)
same_group_detail_list
=
list
()
for
i
in
range
(
0
,
len
(
same_group_user_id_list
),
1000
):
sql_data_list
=
User
.
objects
.
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_group_user_id_list
[
i
:
i
+
1000
])
for
detail_data
in
sql_data_list
:
item
=
{
"user_id"
:
detail_data
.
user_id
,
...
...
@@ -142,7 +142,7 @@ class User(models.Model):
try
:
user_tag_id_list
=
list
()
query_results
=
AccountUserTag
.
objects
.
filter
(
user
=
self
.
user_id
,
is_deleted
=
False
)
query_results
=
AccountUserTag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user
=
self
.
user_id
,
is_deleted
=
False
)
for
item
in
query_results
:
user_tag_id_list
.
append
(
item
.
tag_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