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
b0af8792
Commit
b0af8792
authored
May 16, 2019
by
Kai
Browse files
Options
Browse Files
Download
Plain Diff
update
parents
4478c850
c1b48f9f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
26 deletions
+57
-26
Project.xml
.idea/codeStyles/Project.xml
+25
-0
error.py
libs/error.py
+1
-1
topic.py
search/utils/topic.py
+31
-25
No files found.
.idea/codeStyles/Project.xml
View file @
b0af8792
...
...
@@ -24,5 +24,29 @@
<option
name=
"ITERATION_ELEMENTS_WRAPPING"
value=
"chop_down_if_not_single"
/>
</formatting-settings>
</DBN-SQL>
<DBN-PSQL>
<case-options
enabled=
"false"
>
<option
name=
"KEYWORD_CASE"
value=
"lower"
/>
<option
name=
"FUNCTION_CASE"
value=
"lower"
/>
<option
name=
"PARAMETER_CASE"
value=
"lower"
/>
<option
name=
"DATATYPE_CASE"
value=
"lower"
/>
<option
name=
"OBJECT_CASE"
value=
"preserve"
/>
</case-options>
<formatting-settings
enabled=
"false"
/>
</DBN-PSQL>
<DBN-SQL>
<case-options
enabled=
"false"
>
<option
name=
"KEYWORD_CASE"
value=
"lower"
/>
<option
name=
"FUNCTION_CASE"
value=
"lower"
/>
<option
name=
"PARAMETER_CASE"
value=
"lower"
/>
<option
name=
"DATATYPE_CASE"
value=
"lower"
/>
<option
name=
"OBJECT_CASE"
value=
"preserve"
/>
</case-options>
<formatting-settings
enabled=
"false"
>
<option
name=
"STATEMENT_SPACING"
value=
"one_line"
/>
<option
name=
"CLAUSE_CHOP_DOWN"
value=
"chop_down_if_statement_long"
/>
<option
name=
"ITERATION_ELEMENTS_WRAPPING"
value=
"chop_down_if_not_single"
/>
</formatting-settings>
</DBN-SQL>
</code_scheme>
</component>
\ No newline at end of file
libs/error.py
View file @
b0af8792
...
...
@@ -18,4 +18,4 @@ def logging_exception(send_to_sentry=True):
# send exception info to sentry, fail silently
_sentry_client
.
captureException
()
except
:
pass
pass
raven
.
contrib
.
django
.
raven_compat
.
models
search/utils/topic.py
View file @
b0af8792
...
...
@@ -12,6 +12,7 @@ from .common import TopicDocumentField
from
search.utils.common
import
*
from
trans2es.models.pictorial
import
PictorialTopics
class
TopicUtils
(
object
):
@classmethod
...
...
@@ -120,9 +121,11 @@ class TopicUtils(object):
return
{}
@classmethod
def
get_recommend_topic_ids
(
cls
,
user_id
,
tag_id
,
offset
,
size
,
single_size
,
query
=
None
,
query_type
=
TopicPageType
.
HOME_RECOMMEND
,
filter_topic_id_list
=
[],
test_score
=
False
,
must_topic_id_list
=
[],
recommend_tag_list
=
[],
user_similar_score_list
=
[],
index_type
=
"topic"
,
routing
=
None
,
attention_tag_list
=
[],
linucb_user_id_list
=
[],
disable_collpase
=
False
):
def
get_recommend_topic_ids
(
cls
,
user_id
,
tag_id
,
offset
,
size
,
single_size
,
query
=
None
,
query_type
=
TopicPageType
.
HOME_RECOMMEND
,
filter_topic_id_list
=
[],
test_score
=
False
,
must_topic_id_list
=
[],
recommend_tag_list
=
[],
user_similar_score_list
=
[],
index_type
=
"topic"
,
routing
=
None
,
attention_tag_list
=
[],
linucb_user_id_list
=
[],
disable_collpase
=
False
):
"""
:remark:获取首页推荐帖子列表
:param user_id:
...
...
@@ -244,7 +247,7 @@ class TopicUtils(object):
],
"minimum_should_match"
:
1
,
"must_not"
:
[
{
"term"
:
{
"is_history"
:
True
}}
{
"term"
:
{
"is_history"
:
True
}}
]
}
},
...
...
@@ -260,10 +263,10 @@ class TopicUtils(object):
}
if
len
(
filter_topic_id_list
)
>
0
:
query_function_score
[
"query"
][
"bool"
][
"must_not"
]
=
[
{
"terms"
:
{
"id"
:
filter_topic_id_list
}}
{
"terms"
:
{
"id"
:
filter_topic_id_list
}}
]
if
len
(
linucb_user_id_list
)
>
0
:
if
len
(
linucb_user_id_list
)
>
0
:
if
"must_not"
in
query_function_score
[
"query"
][
"bool"
]:
query_function_score
[
"query"
][
"bool"
][
"must_not"
]
+=
[
{
"terms"
:
{
"user_id"
:
linucb_user_id_list
}}
...
...
@@ -294,7 +297,7 @@ class TopicUtils(object):
]
query_function_score
[
"query"
][
"bool"
][
"minimum_should_match"
]
=
1
query_function_score
[
"query"
][
"bool"
][
"filter"
]
.
append
(
{
"range"
:
{
"content_level"
:
{
"gte"
:
4
,
"lte"
:
6
}}}
{
"range"
:
{
"content_level"
:
{
"gte"
:
4
,
"lte"
:
6
}}}
)
else
:
if
"must_not"
in
query_function_score
[
"query"
][
"bool"
]:
...
...
@@ -347,7 +350,7 @@ class TopicUtils(object):
}
]
result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
sub_index_name
=
index_type
,
query_body
=
q
,
offset
=
offset
,
size
=
size
,
routing
=
routing
)
offset
=
offset
,
size
=
size
,
routing
=
routing
)
topic_id_list
=
list
()
...
...
@@ -360,7 +363,8 @@ class TopicUtils(object):
@classmethod
def
get_topic_detail_recommend_list
(
cls
,
user_id
,
topic_id
,
topic_tag_list
,
topic_pictorial_id
,
topic_user_id
,
filter_topic_user_id
,
have_read_topic_list
,
offset
,
size
,
es_cli_obj
=
None
,
index_type
=
"topic"
,
routing
=
None
):
filter_topic_user_id
,
have_read_topic_list
,
offset
,
size
,
es_cli_obj
=
None
,
index_type
=
"topic"
,
routing
=
None
):
"""
:remark 帖子详情页推荐列表,缺少按时间衰减
:param user_id:
...
...
@@ -437,7 +441,7 @@ class TopicUtils(object):
}
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
sub_index_name
=
index_type
,
query_body
=
q
,
offset
=
offset
,
size
=
size
,
routing
=
routing
)
offset
=
offset
,
size
=
size
,
routing
=
routing
)
return
result_dict
[
"hits"
]
except
:
...
...
@@ -445,9 +449,10 @@ class TopicUtils(object):
return
[]
@classmethod
def
top_get_topic_detail_recommend_list
(
cls
,
user_id
,
topic_id
,
have_read_topic_list
,
size
,
es_cli_obj
=
None
,
index_type
=
"topic"
,
routing
=
None
,
collection_topic_tag_list
=
[],
topic_tag_list
=
[],
topic_user_id
=-
1
):
def
top_get_topic_detail_recommend_list
(
cls
,
user_id
,
topic_id
,
have_read_topic_list
,
size
,
es_cli_obj
=
None
,
index_type
=
"topic"
,
routing
=
None
,
collection_topic_tag_list
=
[],
topic_tag_list
=
[],
topic_user_id
=-
1
):
"""
:remark 帖子详情页推荐列表,缺少按时间衰减
:param user_id:
...
...
@@ -491,7 +496,7 @@ class TopicUtils(object):
# "weight": 5000
# }
# )
if
len
(
topic_tag_list
)
!=
0
or
topic_user_id
!=
-
1
:
if
len
(
topic_tag_list
)
!=
0
or
topic_user_id
!=
-
1
:
query_function_score
=
{
"query"
:
{
"bool"
:
{
...
...
@@ -559,7 +564,8 @@ class TopicUtils(object):
# {"create_time": {"order": "desc"}}
# ]
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
sub_index_name
=
index_type
,
query_body
=
q
,
size
=
size
,
routing
=
routing
)
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
sub_index_name
=
index_type
,
query_body
=
q
,
size
=
size
,
routing
=
routing
)
topic_id_list
=
list
()
for
item
in
result_dict
[
"hits"
]:
...
...
@@ -702,7 +708,7 @@ class TopicUtils(object):
{
"term"
:
{
"is_deleted"
:
False
}},
]
logging
.
info
(
"get filters:
%
s"
%
filters
)
logging
.
info
(
"get filters:
%
s"
%
filters
)
if
not
filters
:
return
f
...
...
@@ -892,21 +898,23 @@ class TopicUtils(object):
query_body
=
q
,
offset
=
offset
,
size
=
size
)
if
len
(
result_dict
[
"hits"
])
>
0
:
if
len
(
result_dict
[
"hits"
])
>
0
:
topic_id_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_dict
[
"hits"
]]
return
(
topic_id_list
,
result_dict
[
"total_count"
])
elif
offset
==
0
and
"pictorial_id"
in
filters
:
# 防止帖子同步延迟,画报详情页为空
return
(
topic_id_list
,
result_dict
[
"total_count"
])
elif
offset
==
0
and
"pictorial_id"
in
filters
:
# 防止帖子同步延迟,画报详情页为空
pictorial_id
=
int
(
filters
[
"pictorial_id"
])
topic_id_list
=
list
(
PictorialTopics
.
objects
.
filter
(
pictorial_id
=
pictorial_id
,
is_online
=
True
,
is_deleted
=
False
)
.
values_list
(
"topic_id"
,
flat
=
True
)[
offset
:
size
])
topic_id_list
=
list
(
PictorialTopics
.
objects
.
filter
(
pictorial_id
=
pictorial_id
,
is_online
=
True
,
is_deleted
=
False
)
.
values_list
(
"topic_id"
,
flat
=
True
)[
offset
:
size
])
return
(
topic_id_list
,
len
(
topic_id_list
))
return
(
topic_id_list
,
len
(
topic_id_list
))
else
:
return
([],
0
)
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
([],
0
)
return
([],
0
)
@classmethod
def
business_topic_ids
(
cls
,
filters
,
nfilters
,
sorts_by
,
offset
=
0
,
size
=
10
,
index_name
=
"topic"
,
filter_online
=
True
):
...
...
@@ -994,7 +1002,6 @@ class TopicUtils(object):
}
}
})
elif
k
==
"drop_score"
:
if
v
==
"0"
:
f
.
append
({
...
...
@@ -1009,7 +1016,6 @@ class TopicUtils(object):
}
}
})
else
:
if
isinstance
(
v
,
list
):
...
...
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