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
b8c19bb7
Commit
b8c19bb7
authored
Mar 20, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
fdf271c5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
24 deletions
+25
-24
workspace.xml
.idea/workspace.xml
+0
-0
group.py
search/utils/group.py
+10
-10
group.py
search/views/group.py
+14
-14
topic.py
trans2es/models/topic.py
+1
-0
No files found.
.idea/workspace.xml
View file @
b8c19bb7
This diff is collapsed.
Click to expand it.
search/utils/group.py
View file @
b8c19bb7
...
...
@@ -47,7 +47,7 @@ class GroupUtils(object):
return
{
"total_count"
:
0
,
"hits"
:[]}
@classmethod
def
get_hot_
group
_recommend_result_list
(
cls
,
offset
,
size
,
es_cli_obj
=
None
):
def
get_hot_
pictorial
_recommend_result_list
(
cls
,
offset
,
size
,
es_cli_obj
=
None
):
try
:
if
not
es_cli_obj
:
es_cli_obj
=
ESPerform
.
get_cli
()
...
...
@@ -68,19 +68,19 @@ class GroupUtils(object):
"includes"
:[
"id"
]
}
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"
group
"
,
q
,
offset
,
size
)
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"
pictorial
"
,
q
,
offset
,
size
)
group
_ids_list
=
[]
pictorial
_ids_list
=
[]
if
len
(
result_dict
[
"hits"
])
>
0
:
group
_ids_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_dict
[
"hits"
]]
pictorial
_ids_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_dict
[
"hits"
]]
return
group
_ids_list
return
pictorial
_ids_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
@classmethod
def
get_user_attention_
group
_list
(
cls
,
user_id
,
offset
=
0
,
size
=
10
,
es_cli_obj
=
None
):
def
get_user_attention_
pictorial
_list
(
cls
,
user_id
,
offset
=
0
,
size
=
10
,
es_cli_obj
=
None
):
"""
:remark: 获取用户关注小组列表
:return:
...
...
@@ -100,12 +100,12 @@ class GroupUtils(object):
}
}
q
[
"_source"
]
=
{
"includes"
:[
"attention_
group
_id_list"
]
"includes"
:[
"attention_
pictorial
_id_list"
]
}
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"user"
,
q
,
offset
,
size
)
if
len
(
result_dict
[
"hits"
])
>
0
:
return
result_dict
[
"hits"
][
0
][
"_source"
][
"attention_
group
_id_list"
]
return
result_dict
[
"hits"
][
0
][
"_source"
][
"attention_
pictorial
_id_list"
]
else
:
return
[]
except
:
...
...
@@ -113,7 +113,7 @@ class GroupUtils(object):
return
[]
@classmethod
def
get_group_ids_by_aggs
(
cls
,
group_id
_list
,
es_cli_obj
=
None
):
def
get_group_ids_by_aggs
(
cls
,
pictorial_ids
_list
,
es_cli_obj
=
None
):
"""
:remark:聚合查询获取小组列表
:param group_id_list:
...
...
@@ -127,7 +127,7 @@ class GroupUtils(object):
q
[
"size"
]
=
0
q
[
"query"
]
=
{
"terms"
:{
"
group_id"
:
group_id
_list
"
pictorial_id"
:
pictorial_ids
_list
}
}
q
[
"aggs"
]
=
{
...
...
search/views/group.py
View file @
b8c19bb7
...
...
@@ -51,27 +51,27 @@ def group_sort(user_id=-1,sort_type=GroupSortTypes.HOT_RECOMMEND,offset=0,size=1
es_cli_obj
=
ESPerform
.
get_cli
()
if
sort_type
==
GroupSortTypes
.
HOT_RECOMMEND
:
group_ids_list
=
GroupUtils
.
get_hot_group
_recommend_result_list
(
offset
,
size
,
es_cli_obj
)
pictorial_ids_list
=
GroupUtils
.
get_hot_pictorial
_recommend_result_list
(
offset
,
size
,
es_cli_obj
)
return
{
"
group_recommend_ids"
:
group
_ids_list
}
return
{
"
pictorial_recommend_ids"
:
pictorial
_ids_list
}
elif
sort_type
==
GroupSortTypes
.
ATTENTION_RECOMMEND
:
attention_
group_list
=
GroupUtils
.
get_user_attention_group
_list
(
user_id
,
offset
=
0
,
size
=
1
,
es_cli_obj
=
es_cli_obj
)
if
len
(
attention_
group
_list
)
==
0
:
return
{
"
group
_recommend_ids"
:
[]}
attention_
pictorial_list
=
GroupUtils
.
get_user_attention_pictorial
_list
(
user_id
,
offset
=
0
,
size
=
1
,
es_cli_obj
=
es_cli_obj
)
if
len
(
attention_
pictorial
_list
)
==
0
:
return
{
"
pictorial
_recommend_ids"
:
[]}
else
:
attention_
group_id_list
=
[
item
[
"group_id"
]
for
item
in
attention_group
_list
]
sorted_
group_ids_list
=
GroupUtils
.
get_group_ids_by_aggs
(
attention_group
_id_list
,
es_cli_obj
)
attention_
pictorial_id_list
=
[
item
[
"pictorial_id"
]
for
item
in
attention_pictorial
_list
]
sorted_
pictorial_ids_list
=
GroupUtils
.
get_group_ids_by_aggs
(
attention_pictorial
_id_list
,
es_cli_obj
)
group_recommend_ids_list
=
sorted_group
_ids_list
pictorial_recommend_ids_list
=
sorted_pictorial
_ids_list
#if len(group_recommend_ids_list) < size and len(group_recommend_ids_list)<len(attention_group_list):
sorted_attention_
group_list
=
sorted
(
attention_group
_list
,
key
=
lambda
item
:
item
[
"update_time_val"
],
reverse
=
True
)
for
item
in
sorted_attention_
group
_list
:
if
item
[
"group_id"
]
not
in
group
_recommend_ids_list
:
group
_recommend_ids_list
.
append
(
item
[
"group_id"
])
sorted_attention_
pictorial_list
=
sorted
(
attention_pictorial
_list
,
key
=
lambda
item
:
item
[
"update_time_val"
],
reverse
=
True
)
for
item
in
sorted_attention_
pictorial
_list
:
if
item
[
"group_id"
]
not
in
pictorial
_recommend_ids_list
:
pictorial
_recommend_ids_list
.
append
(
item
[
"group_id"
])
return
{
"
group_recommend_ids"
:
group
_recommend_ids_list
[
offset
:(
offset
+
size
)]}
return
{
"
pictorial_recommend_ids"
:
pictorial
_recommend_ids_list
[
offset
:(
offset
+
size
)]}
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
"
group
_recommend_ids"
:[]}
return
{
"
pictorial
_recommend_ids"
:[]}
trans2es/models/topic.py
View file @
b8c19bb7
...
...
@@ -87,6 +87,7 @@ class Topic(models.Model):
def
get_pictorial_id
(
self
):
try
:
pictorial_id
=
PictorialTopic
.
objects
.
filter
(
topic_id
=
self
.
id
)
logging
.
info
(
"get user attention pictorial id :
%
s"
%
pictorial_id
)
return
pictorial_id
except
:
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