Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
search_tips
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
rank
search_tips
Commits
150b402a
Commit
150b402a
authored
Jun 28, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
判断类型
parent
f4c5578d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
15 deletions
+28
-15
agile_tag.py
associate/models/agile_tag.py
+3
-4
auto_tips.py
associate/search/utils/auto_tips.py
+23
-8
agile_tag_transfer.py
associate/utils/agile_tag_transfer.py
+2
-3
No files found.
associate/models/agile_tag.py
View file @
150b402a
...
@@ -48,10 +48,9 @@ class AgileTagType(BaseModel):
...
@@ -48,10 +48,9 @@ class AgileTagType(BaseModel):
@property
@property
def
get_by_id_name
(
self
):
def
get_by_id_name
(
self
):
try
:
try
:
logging
.
info
(
"get self.id:
%
s"
%
self
.
agile_tag_id
)
logging
.
info
(
"get self.id:
%
s"
%
self
.
agile_tag_id
)
results
=
AgileTag
.
objects
.
filter
(
id
=
self
.
agile_tag_id
)
.
values
()
.
first
()
results
=
AgileTag
.
objects
.
filter
(
id
=
self
.
agile_tag_id
)
.
values
()
.
first
()
if
results
:
if
results
:
return
results
return
results
else
:
else
:
return
{}
return
{}
...
...
associate/search/utils/auto_tips.py
View file @
150b402a
...
@@ -52,15 +52,30 @@ def get_suggest_tips(query, agile_tag_type):
...
@@ -52,15 +52,30 @@ def get_suggest_tips(query, agile_tag_type):
for
tips_item
in
result_dicts
[
"hits"
][
"hits"
]:
for
tips_item
in
result_dicts
[
"hits"
][
"hits"
]:
agile_type_id
.
add
(
tips_item
[
"_source"
][
"agile_tag_id"
])
agile_type_id
.
add
(
tips_item
[
"_source"
][
"agile_tag_id"
])
logging
.
info
(
"get agile_type_id:
%
s"
%
agile_type_id
)
logging
.
info
(
"get agile_type_id:
%
s"
%
agile_type_id
)
# 获取这个类型
# 获取这个类型
logging
.
info
(
"get result_dict:
%
s"
%
result_dict
)
logging
.
info
(
"get result_dict:
%
s"
%
result_dict
)
for
tips_item
in
result_dict
[
"suggest"
][
"tips-suggest"
]:
for
tips_item
in
result_dict
[
"suggest"
][
"tips-suggest"
]:
for
hit_item
in
tips_item
[
"options"
]:
for
hit_item
in
tips_item
[
"options"
]:
if
hit_item
[
"_source"
][
"ori_name"
]
not
in
have_read_tips_set
:
if
hit_item
[
"_source"
][
"ori_name"
]
not
in
have_read_tips_set
:
agile_tag_id
=
hit_item
[
"_source"
][
"agile_tag_id"
]
agile_tag_id
=
hit_item
[
"_source"
][
"agile_tag_id"
]
if
agile_tag_id
in
agile_type_id
:
if
agile_tag_id
in
agile_type_id
:
have_read_tips_set
.
add
(
hit_item
[
"_source"
][
"ori_name"
])
highlight_marks
=
u'<ems>
%
s</ems>'
%
query
hit_item
[
"_source"
][
"highlight_name"
]
=
hit_item
[
"_source"
][
"ori_name"
]
.
replace
(
query
,
highlight_marks
)
ori_name
=
hit_item
[
"_source"
][
"ori_name"
]
results_num
=
hit_item
[
"_source"
][
"results_num"
]
highlight_name
=
hit_item
[
"_source"
][
"highlight_name"
]
ret_list
.
append
(
[{
"ori_name"
:
ori_name
,
"results_num"
:
results_num
,
"highlight"
:
highlight_name
}])
else
:
for
tips_item
in
result_dict
[
"suggest"
][
"tips-suggest"
]:
for
hit_item
in
tips_item
[
"options"
]:
if
hit_item
[
"_source"
][
"ori_name"
]
not
in
have_read_tips_set
:
have_read_tips_set
.
add
(
hit_item
[
"_source"
][
"ori_name"
])
have_read_tips_set
.
add
(
hit_item
[
"_source"
][
"ori_name"
])
highlight_marks
=
u'<ems>
%
s</ems>'
%
query
highlight_marks
=
u'<ems>
%
s</ems>'
%
query
hit_item
[
"_source"
][
"highlight_name"
]
=
hit_item
[
"_source"
][
"ori_name"
]
.
replace
(
query
,
hit_item
[
"_source"
][
"highlight_name"
]
=
hit_item
[
"_source"
][
"ori_name"
]
.
replace
(
query
,
...
...
associate/utils/agile_tag_transfer.py
View file @
150b402a
...
@@ -95,13 +95,12 @@ class TagTransfer(object):
...
@@ -95,13 +95,12 @@ class TagTransfer(object):
def
set_data_to_redis
(
self
,
instance
):
def
set_data_to_redis
(
self
,
instance
):
try
:
try
:
query_key
=
"query:associate_tip:tag_id:"
query_key
=
"query:associate_tip:tag_id:"
name
=
agile_tag
.
AgileTag
.
objects
.
filter
(
id
=
instance
.
agile_tag_id
)
.
values_list
(
"name"
,
flat
=
True
)
.
first
()
name
=
agile_tag
.
AgileTag
.
objects
.
filter
(
id
=
instance
.
agile_tag_id
)
.
values_list
(
"name"
,
flat
=
True
)
.
first
()
tractate_results
=
TagTransfer
.
get_tractate_data_name_mapping_results_to_redis
(
name
)
tractate_results
=
TagTransfer
.
get_tractate_data_name_mapping_results_to_redis
(
name
)
if
tractate_results
==
None
:
tractate_results
=
0
logging
.
info
(
"get tractate_results:
%
s"
%
tractate_results
)
logging
.
info
(
"get tractate_results:
%
s"
%
tractate_results
)
key
=
query_key
+
str
(
instance
.
agile_tag_id
)
key
=
query_key
+
str
(
instance
.
agile_tag_id
)
redis_client
.
set
(
key
,
tractate_results
)
redis_client
.
set
(
key
,
tractate_results
)
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