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
de0e0e68
Commit
de0e0e68
authored
Jul 02, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
94fd6acc
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
33 deletions
+48
-33
associate_tag.json
associate/mapping/associate_tag.json
+2
-1
agile_tag.py
associate/models/agile_tag.py
+33
-12
type_info.py
associate/type_info.py
+3
-6
agile_tag_transfer.py
associate/utils/agile_tag_transfer.py
+10
-14
No files found.
associate/mapping/associate_tag.json
View file @
de0e0e68
...
...
@@ -22,6 +22,7 @@
"agile_tag_id"
:{
"type"
:
"long"
},
//标签ID
"create_tag_type"
:{
"type"
:
"long"
},
//标签创建类型
"style"
:{
"type"
:
"long"
},
//新标签样式
"topic_recommend_sort"
:{
"type"
:
"long"
}
"topic_recommend_sort"
:{
"type"
:
"long"
},
"api_agile_tag_recommend_type"
:{
"type"
:
"long"
}
}
}
associate/models/agile_tag.py
View file @
de0e0e68
...
...
@@ -35,6 +35,23 @@ class AgileTag(BaseModel):
style
=
models
.
CharField
(
verbose_name
=
u"标签样式"
,
max_length
=
3
,
choices
=
AGILE_TAG_STYLE
)
topic_recommend_sort
=
models
.
IntegerField
(
verbose_name
=
u'帖子推荐排序'
,
default
=
9999
)
def
get_agile_tag_type
(
self
):
try
:
results
=
AgileTagType
.
objects
.
filter
(
agile_tag_id
=
self
.
id
)
.
values_list
(
"agile_tag_type"
,
flat
=
True
)
.
first
()
return
results
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
None
def
get_api_agile_tag_recommend_type
(
self
):
try
:
results
=
AgileTagRecommendType
.
objects
.
filter
(
agile_tag_id
=
self
.
id
)
.
values_list
(
"agile_tag_type"
,
flat
=
True
)
.
first
()
return
results
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
None
class
AgileTagType
(
BaseModel
):
class
Meta
:
...
...
@@ -45,15 +62,19 @@ class AgileTagType(BaseModel):
agile_tag_id
=
models
.
IntegerField
(
verbose_name
=
u'新标签'
,
db_index
=
True
)
agile_tag_type
=
models
.
CharField
(
verbose_name
=
u"标签类型"
,
max_length
=
3
,
choices
=
AGILE_TAG_TYPE
)
@property
def
get_by_id_name
(
self
):
try
:
logging
.
info
(
"get self.id:
%
s"
%
self
.
agile_tag_id
)
results
=
AgileTag
.
objects
.
filter
(
id
=
self
.
agile_tag_id
)
.
values
()
.
first
()
if
results
:
return
results
else
:
return
{}
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
{}
class
ApiAgileTagRecommendType
(
BaseModel
):
class
Meta
:
verbose_name
=
u'新标签推荐类型'
db_table
=
'api_agile_tag_recommend_type'
app_label
=
'api'
class
AgileTagRecommendType
(
BaseModel
):
class
Meta
:
verbose_name
=
u'新标签推荐类型'
db_table
=
'api_agile_tag_recommend_type'
agile_tag_id
=
models
.
IntegerField
(
verbose_name
=
u'新标签'
,
db_index
=
True
)
agile_tag_type
=
models
.
CharField
(
verbose_name
=
u"标签推荐类型"
,
max_length
=
3
,
choices
=
AGILE_TAG_RECOMMEND_TYPE
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u"是否有效"
,
default
=
True
)
associate/type_info.py
View file @
de0e0e68
...
...
@@ -10,6 +10,7 @@ import copy
from
libs.es
import
ESPerform
from
associate.models
import
agile_tag
from
associate.utils.agile_tag_transfer
import
TagTransfer
from
gm_types.gaia
import
(
AGILE_TAG_TYPE
,
)
...
...
@@ -243,9 +244,7 @@ def get_type_info_map():
name
=
'associate_tag'
,
type
=
'associate_tag'
,
model
=
agile_tag
.
AgileTagType
,
query_deferred
=
lambda
:
agile_tag
.
AgileTagType
.
objects
.
filter
(
agile_tag_type__in
=
[
AGILE_TAG_TYPE
.
PROJECT
,
AGILE_TAG_TYPE
.
POSITION
,
AGILE_TAG_TYPE
.
BRAND
,
AGILE_TAG_TYPE
.
INSTRUMENT
,
AGILE_TAG_TYPE
.
HOSPITAL
,
AGILE_TAG_TYPE
.
DOCTOR
])
.
query
,
query_deferred
=
lambda
:
agile_tag
.
AgileTag
.
objects
.
all
()
.
query
,
get_data_func
=
TagTransfer
.
get_tag_suggest_data_list
,
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
...
...
@@ -272,9 +271,7 @@ def tips_attr_sync_to_redis_type_info_map():
name
=
'associate'
,
type
=
'associate_results_num'
,
# api_wordrelresemble
model
=
agile_tag
.
AgileTagType
,
query_deferred
=
lambda
:
agile_tag
.
AgileTagType
.
objects
.
filter
(
agile_tag_type__in
=
[
AGILE_TAG_TYPE
.
PROJECT
,
AGILE_TAG_TYPE
.
POSITION
,
AGILE_TAG_TYPE
.
BRAND
,
AGILE_TAG_TYPE
.
INSTRUMENT
,
AGILE_TAG_TYPE
.
HOSPITAL
,
AGILE_TAG_TYPE
.
DOCTOR
])
.
query
,
query_deferred
=
lambda
:
agile_tag
.
AgileTag
.
objects
.
all
()
.
query
,
get_data_func
=
TagTransfer
.
set_data_to_redis
,
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
...
...
associate/utils/agile_tag_transfer.py
View file @
de0e0e68
...
...
@@ -24,26 +24,22 @@ class TagTransfer(object):
ret_list
=
list
()
item_dict
=
dict
()
results
=
instance
.
get_by_id_name
logging
.
info
(
"get results:
%
s"
%
results
)
name
=
results
.
get
(
"name"
,
None
)
item_dict
[
"id"
]
=
getMd5Digest
(
str
(
name
))
item_dict
[
"ori_name"
]
=
name
item_dict
[
"is_online"
]
=
results
.
get
(
"is_online"
,
None
)
# item_dict["results_num"] = QueryWordAttr.get_query_results_num(instance.agile_tag_id)
item_dict
[
"id"
]
=
getMd5Digest
(
str
(
instance
.
name
))
item_dict
[
"ori_name"
]
=
instance
.
name
.
strip
()
item_dict
[
"is_online"
]
=
instance
.
is_online
random_num
=
random
.
randint
(
3000
,
10000
)
item_dict
[
"results_num"
]
=
random_num
item_dict
[
"agile_tag_type"
]
=
instance
.
agile_tag_type
item_dict
[
"agile_tag_id"
]
=
instance
.
agile_tag_id
item_dict
[
"create_tag_type"
]
=
results
.
get
(
"create_tag_type"
,
None
)
item_dict
[
"style"
]
=
results
.
get
(
"style"
,
None
)
item_dict
[
"topic_recommend_sort"
]
=
results
.
get
(
"topic_recommend_sort"
,
None
)
item_dict
[
"offline_score"
]
=
0.0
item_dict
[
"create_tag_type"
]
=
instance
.
create_tag_type
item_dict
[
"style"
]
=
instance
.
style
item_dict
[
"topic_recommend_sort"
]
=
instance
.
topic_recommend_sort
item_dict
[
"agile_tag_type"
]
=
instance
.
get_agile_tag_type
()
item_dict
[
"agile_tag_id"
]
=
instance
.
id
item_dict
[
"api_agile_tag_recommend_type"
]
=
instance
.
get_api_agile_tag_recommend_type
()
ret_list
.
append
(
item_dict
)
suggest_list
=
get_tips_suggest_list
(
name
)
suggest_list
=
get_tips_suggest_list
(
instance
.
name
)
logging
.
info
(
"get ret_list:
%
s"
%
ret_list
)
logging
.
info
(
"get suggest_list:
%
s"
%
ret_list
)
return
(
item_dict
,
suggest_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