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
05a61dff
Commit
05a61dff
authored
Jul 31, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
49107683
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
136 additions
and
0 deletions
+136
-0
group.py
search/views/group.py
+136
-0
No files found.
search/views/group.py
View file @
05a61dff
...
...
@@ -135,6 +135,7 @@ def pictorial_sort1(user_id=-1, sort_type=GroupSortTypes.HOT_RECOMMEND, offset=0
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
"pictorial_recommend_ids"
:
[]}
def
pictorial_topic
(
topic_id
=-
1
,
offset
=
0
,
size
=
10
):
"""
:remark 入选画报
...
...
@@ -355,6 +356,141 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10):
return
{
"pict_pictorial_ids_list"
:
[]}
@bind
(
"physical/search/pictorial_topic"
)
def
pictorial_topic_v1
(
topic_id
=-
1
,
offset
=
0
,
size
=
10
):
"""
:remark 入选画报
:param user_id:
:param sort_type:
:param offset:
:param size:
:return:
"""
try
:
# 获取es链接对象
es_cli_obj
=
ESPerform
.
get_cli
()
q
=
{}
# 获取帖子从属的画报
q
[
"query"
]
=
{
"bool"
:
{
"must"
:
[
{
"term"
:
{
"id"
:
topic_id
}
},
{
"term"
:
{
"is_online"
:
True
}
}
],
"must_not"
:
[
{
"term"
:
{
"is_history"
:
True
}
}
]
}
}
q
[
"_source"
]
=
{
"includes"
:
[
"id"
,
"pictorial_id"
,
"edit_tag_list"
]
}
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"topic"
,
q
,
offset
=
0
,
size
=
1
)
edit_tag_list
=
[]
pictorial_id_list
=
[]
if
len
(
result_dict
[
"hits"
])
>
0
:
for
item
in
result_dict
[
"hits"
]:
edit_tag_list
=
item
[
"_source"
][
"edit_tag_list"
]
functions_list
=
[
{
"filter"
:
{
"bool"
:
{
"must"
:
{
"term"
:
{
"topic_id_list"
:
topic_id
}
}
}
},
"weight"
:
200
},
{
"filter"
:
{
"bool"
:
{
"must"
:
{
"term"
:
{
"is_recommend"
:
True
}
}
}
},
"weight"
:
100
}
]
query_function_score
=
{
"query"
:
{
"bool"
:
{
"must"
:
[{
"terms"
:
{
"edit_tag_list"
:
edit_tag_list
}
},
{
"term"
:
{
"is_online"
:
True
}
},
{
"term"
:
{
"is_deleted"
:
False
}
},
]
}
},
"score_mode"
:
"sum"
,
"boost_mode"
:
"replace"
,
"functions"
:
functions_list
}
q
[
"query"
]
=
{
"function_score"
:
query_function_score
}
q
[
"_source"
]
=
{
"includes"
:
[
"id"
,
"edit_tag_list"
,
"topic_id_list"
]
}
q
[
"sort"
]
=
[
{
"_script"
:
{
"type"
:
"number"
,
"script"
:
{
"lang"
:
"expression"
,
"source"
:
"_score+doc['reply_score']"
},
"order"
:
"desc"
}
}
]
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"pictorial"
,
q
,
offset
,
size
)
if
len
(
result_dict
[
"hits"
])
>
0
:
for
item
in
result_dict
[
"hits"
]:
pictorial_id
=
item
[
"_source"
][
"id"
]
pictorial_id_list
.
append
(
pictorial_id
)
return
{
"pictorial_ids_list"
:
pictorial_id_list
}
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
"pictorial_ids_list"
:
[]}
@bind
(
"physical/search/pictorial_sort"
)
def
pictorial_sort
(
user_id
=-
1
,
sort_type
=
GroupSortTypes
.
HOT_RECOMMEND
,
offset
=
0
,
size
=
10
,
device_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