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
6edfff1d
Commit
6edfff1d
authored
5 years ago
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
40cea006
master
deploy/like-prod
deploy/like-stage
deploy/like-test
dev
like-pre/r01
test
2 merge requests
!381
Master
,
!406
Pictorial topic recomment
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
47 deletions
+20
-47
type_info.py
trans2es/type_info.py
+5
-43
tag_transfer.py
trans2es/utils/tag_transfer.py
+15
-4
No files found.
trans2es/type_info.py
View file @
6edfff1d
...
...
@@ -144,49 +144,13 @@ class TypeInfo(object):
else
:
if
data
:
if
self
.
type
==
"topic"
:
# q = {
# "query":{
# "term":{
# "id": data["id"]
# }
# },
# "_source":{
# "include":["content_level"]
# }
# }
# search_results = ESPerform.get_search_results(ESPerform.get_cli(),sub_index_name="topic-star",query_body=q,offset=0,size=1)
# if len(search_results["hits"]) > 0:
# ori_topic_star = search_results["hits"][0]["_source"]["content_level"]
# else:
ori_topic_star
=
redis_client
.
hget
(
self
.
physical_topic_star
,
data
[
"id"
])
if
ori_topic_star
:
ori_topic_star
=
str
(
ori_topic_star
,
encoding
=
"utf-8"
)
# else:
# q = {
# "query":{
# "term":{
# "id": data["id"]
# }
# },
# "_source":{
# "includes":["content_level"]
# }
# }
# search_results = ESPerform.get_search_results(ESPerform.get_cli(),sub_index_name="topic-star",query_body=q,offset=0,size=1)
# if len(search_results["hits"]) > 0:
# ori_topic_star = search_results["hits"][0]["_source"]["content_level"]
if
not
ori_topic_star
:
# data_list = [
# {
# "id": data["id"],
# "content_level": data["content_level"]
# }
# ]
# ESPerform.es_helpers_bulk(ESPerform.get_cli(), data_list, "topic-star")
redis_client
.
hset
(
self
.
physical_topic_star
,
data
[
"id"
],
data
[
"content_level"
])
else
:
# int_ori_topic_star = int(str(ori_topic_star, encoding="utf-8"))
int_ori_topic_star
=
int
(
ori_topic_star
)
if
int_ori_topic_star
!=
data
[
"content_level"
]:
old_data
=
copy
.
deepcopy
(
data
)
...
...
@@ -199,17 +163,15 @@ class TypeInfo(object):
if
int_ori_topic_star
>=
4
:
topic_data_high_star_list
.
append
(
old_data
)
redis_client
.
hset
(
self
.
physical_topic_star
,
data
[
"id"
],
data
[
"content_level"
])
# data_list = [
# {
# "id": data["id"],
# "content_level": data["content_level"]
# }
# ]
# ESPerform.es_helpers_bulk(ESPerform.get_cli(), data_list, "topic-star")
if
data
[
"content_level"
]
and
int
(
data
[
"content_level"
])
>=
4
:
topic_data_high_star_list
.
append
(
data
)
elif
self
.
type
==
"tag"
or
self
.
type
==
"tag_v1"
:
(
res
,
begin_res
)
=
data
data_list
.
append
(
res
)
data_list
.
append
(
begin_res
)
else
:
data_list
.
append
(
data
)
return
(
data_list
,
topic_data_high_star_list
)
...
...
This diff is collapsed.
Click to expand it.
trans2es/utils/tag_transfer.py
View file @
6edfff1d
...
...
@@ -11,7 +11,7 @@ from trans2es.models.topic import Topic
from
trans2es.models.tag
import
TopicTag
,
CommunityTagType
,
CommunityTagTypeRelation
import
datetime
from
django.conf
import
settings
import
copy
class
TagTransfer
(
object
):
...
...
@@ -34,15 +34,20 @@ class TagTransfer(object):
res
[
"id"
]
=
instance
.
id
begin_tag_name_terms_list
=
list
()
tag_name_terms_list
=
list
()
for
i
in
range
(
len
(
instance
.
name
)):
for
j
in
range
(
i
,
len
(
instance
.
name
)
+
1
):
name_term
=
instance
.
name
[
i
:
j
]
.
strip
()
if
name_term
:
if
i
==
0
:
begin_tag_name_terms_list
.
append
(
name_term
.
lower
())
else
:
tag_name_terms_list
.
append
(
name_term
.
lower
())
res
[
"suggest"
]
=
{
"input"
:
tag_name_terms_list
,
"weight"
:
1
,
"contexts"
:{
"is_online"
:
[
instance
.
is_online
],
"is_deleted"
:
[
instance
.
is_deleted
]
...
...
@@ -80,7 +85,13 @@ class TagTransfer(object):
res
[
"collection"
]
=
instance
.
collection
res
[
"is_ai"
]
=
instance
.
is_ai
res
[
"is_own"
]
=
instance
.
is_own
return
res
begin_res
=
copy
.
deepcopy
(
res
)
begin_res
[
"id"
]
=
str
(
begin_res
[
"id"
])
+
"_begin"
begin_res
[
"suggest"
][
"input"
]
=
begin_tag_name_terms_list
begin_res
[
"suggest"
][
"weight"
]
=
10
return
(
res
,
begin_res
)
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
dict
()
\ No newline at end of file
return
(
dict
(),
dict
())
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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