Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
mentha
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
1
Merge Requests
1
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
mentha
Commits
3653b471
Commit
3653b471
authored
Jan 12, 2021
by
李小芳
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'operator_tag' into 'master'
Operator tag See merge request
!19
parents
ebc41366
cc85a7f9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
34 deletions
+87
-34
transfer.py
data_sync/answer/transfer.py
+35
-8
transfer.py
data_sync/tractate/transfer.py
+34
-7
answer.py
qa/models/answer.py
+9
-0
tractate.py
talos/models/tractate/tractate.py
+9
-19
No files found.
data_sync/answer/transfer.py
View file @
3653b471
...
...
@@ -10,13 +10,14 @@ from tags.services.tag import (get_tagv3_analysis_info, get_tag_v3_operators_tag
get_tag_v3_gossip_tag_ids
)
from
talos.services.convert_service.user_convert_service
import
UserConvertService
from
data_sync.tractate.transfer
import
get_keynote_sentence
from
gm_types.gaia
import
DOCTOR_TYPE
from
gm_types.gaia
import
DOCTOR_TYPE
,
TAG_TYPE
from
talos.services.doctor
import
DoctorService
import
time
import
datetime
from
django.conf
import
settings
import
redis
from
algorithm.text_classifical.base
import
model
as
alo_model
from
gm_types.doris
import
SELECTED_CONTENT_TYPE
rpc
=
get_rpc_invoker
()
...
...
@@ -192,13 +193,39 @@ def get_answers(pks):
item
[
"gossip_tag_ids"
]
=
get_tag_v3_gossip_tag_ids
(
content_id
=
answer
.
id
,
content_type
=
"answer"
)
item
[
"gossip_tags"
]
=
get_tag_v3_gossip_tag_ids
(
content_id
=
answer
.
id
,
content_type
=
"answer"
,
get_names
=
True
)
# 首页精选增加内容分类和明星列表和网红列表
result_data
=
alo_model
.
run
(
answer
.
content
)
item
[
'selected_content_type'
]
=
int
(
result_data
.
get
(
"content_type"
,
0
))
item
[
'selected_internet_celebrity'
]
=
[
list
(
item
.
keys
())[
0
]
for
item
in
result_data
.
get
(
"celebrity"
,
[])]
item
[
'selected_stars'
]
=
[
list
(
item
.
keys
())[
0
]
for
item
in
result_data
.
get
(
"star"
,
[])]
projects
=
[
list
(
item
.
keys
())[
0
]
for
item
in
result_data
.
get
(
"projects"
,
[])]
item
[
'portrait_tag_name'
]
.
extend
(
projects
)
# 首页精选增加内容分类 明星列表和网红列表
tagv4
=
answer
.
get_answer_tagv4_names
(
answer_id
=
answer
.
id
)
if
tagv4
:
tags_info
=
answer
.
get_tag
(
tagv4
)
item
[
'selected_stars'
]
=
[]
item
[
'selected_internet_celebrity'
]
=
[]
all_tags
=
[]
for
item
in
tags_info
:
all_tags
.
append
(
item
.
get
(
"id"
,
None
))
if
item
.
get
(
"tag_type"
,
0
)
==
TAG_TYPE
.
STAR
:
item
[
'selected_stars'
]
.
append
(
item
.
get
(
"name"
,
None
))
elif
item
.
get
(
"tag_type"
,
0
)
==
TAG_TYPE
.
INFLUENCER
:
item
[
'selected_internet_celebrity'
]
.
append
(
item
.
get
(
"name"
,
None
))
else
:
pass
if
15928
in
all_tags
:
item
[
'selected_content_type'
]
=
SELECTED_CONTENT_TYPE
.
BEAUTY_STAR
elif
10682
in
all_tags
:
item
[
'selected_content_type'
]
=
SELECTED_CONTENT_TYPE
.
STAR_GOSSIP
elif
15930
in
all_tags
:
item
[
'selected_content_type'
]
=
SELECTED_CONTENT_TYPE
.
BEAUTY_CELEBRITY
elif
10683
in
all_tags
:
item
[
'selected_content_type'
]
=
SELECTED_CONTENT_TYPE
.
CELEBRITY_GOSSIP
else
:
item
[
'selected_content_type'
]
=
-
1
else
:
result_data
=
alo_model
.
run
(
answer
.
content
)
item
[
'selected_content_type'
]
=
int
(
result_data
.
get
(
"content_type"
,
0
))
item
[
'selected_internet_celebrity'
]
=
[
list
(
item
.
keys
())[
0
]
for
item
in
result_data
.
get
(
"celebrity"
,
[])]
item
[
'selected_stars'
]
=
[
list
(
item
.
keys
())[
0
]
for
item
in
result_data
.
get
(
"star"
,
[])]
projects
=
[
list
(
item
.
keys
())[
0
]
for
item
in
result_data
.
get
(
"projects"
,
[])]
item
[
'portrait_tag_name'
]
.
extend
(
projects
)
if
3315
in
item
[
'operators_add_tags'
]:
item
[
'new_smr'
]
=
answer
.
get_answer_newuser_smr
(
answer_id
=
answer
.
id
)
...
...
data_sync/tractate/transfer.py
View file @
3653b471
...
...
@@ -21,6 +21,7 @@ import redis
import
re
import
traceback
from
algorithm.text_classifical.base
import
model
as
alo_model
from
gm_types.doris
import
SELECTED_CONTENT_TYPE
def
get_tractate
(
pks
):
...
...
@@ -231,13 +232,39 @@ def get_tractate(pks):
item
[
"gossip_tags"
]
=
get_tag_v3_gossip_tag_ids
(
content_id
=
tractate
.
id
,
content_type
=
"tractate"
,
get_names
=
True
)
# 首页精选增加内容分类和明星列表和网红列表
result_data
=
alo_model
.
run
(
tractate
.
content
)
item
[
'selected_content_type'
]
=
int
(
result_data
.
get
(
"content_type"
,
0
))
item
[
'selected_internet_celebrity'
]
=
[
list
(
item
.
keys
())[
0
]
for
item
in
result_data
.
get
(
"celebrity"
,
[])]
item
[
'selected_stars'
]
=
[
list
(
item
.
keys
())[
0
]
for
item
in
result_data
.
get
(
"star"
,
[])]
projects
=
[
list
(
item
.
keys
())[
0
]
for
item
in
result_data
.
get
(
"projects"
,
[])]
item
[
'portrait_tag_name'
]
.
extend
(
projects
)
# 首页精选增加内容分类 明星列表和网红列表
tagv4
=
tractate
.
get_tractate_tagv4_names
(
tractate_id
=
tractate
.
id
)
if
tagv4
:
tags_info
=
tractate
.
get_tag
(
tagv4
)
item
[
'selected_stars'
]
=
[]
item
[
'selected_internet_celebrity'
]
=
[]
all_tags
=
[]
for
item
in
tags_info
:
all_tags
.
append
(
item
.
get
(
"id"
,
None
))
if
item
.
get
(
"tag_type"
,
0
)
==
TAG_TYPE
.
STAR
:
item
[
'selected_stars'
]
.
append
(
item
.
get
(
"name"
,
None
))
elif
item
.
get
(
"tag_type"
,
0
)
==
TAG_TYPE
.
INFLUENCER
:
item
[
'selected_internet_celebrity'
]
.
append
(
item
.
get
(
"name"
,
None
))
else
:
pass
if
15928
in
all_tags
:
item
[
'selected_content_type'
]
=
SELECTED_CONTENT_TYPE
.
BEAUTY_STAR
elif
10682
in
all_tags
:
item
[
'selected_content_type'
]
=
SELECTED_CONTENT_TYPE
.
STAR_GOSSIP
elif
15930
in
all_tags
:
item
[
'selected_content_type'
]
=
SELECTED_CONTENT_TYPE
.
BEAUTY_CELEBRITY
elif
10683
in
all_tags
:
item
[
'selected_content_type'
]
=
SELECTED_CONTENT_TYPE
.
CELEBRITY_GOSSIP
else
:
item
[
'selected_content_type'
]
=
-
1
else
:
result_data
=
alo_model
.
run
(
tractate
.
content
)
item
[
'selected_content_type'
]
=
int
(
result_data
.
get
(
"content_type"
,
0
))
item
[
'selected_internet_celebrity'
]
=
[
list
(
item
.
keys
())[
0
]
for
item
in
result_data
.
get
(
"celebrity"
,
[])]
item
[
'selected_stars'
]
=
[
list
(
item
.
keys
())[
0
]
for
item
in
result_data
.
get
(
"star"
,
[])]
projects
=
[
list
(
item
.
keys
())[
0
]
for
item
in
result_data
.
get
(
"projects"
,
[])]
item
[
'portrait_tag_name'
]
.
extend
(
projects
)
if
3315
in
item
[
'operators_add_tags'
]:
item
[
'new_smr'
]
=
tractate
.
get_tractate_newuser_smr
(
tractate_id
=
tractate
.
id
)
...
...
qa/models/answer.py
View file @
3653b471
...
...
@@ -1021,6 +1021,15 @@ class Answer(models.Model):
else
:
return
0
def
get_answer_tagv4_names
(
self
,
answer_id
):
try
:
data
=
AnswerTagV4
.
objects
.
using
(
settings
.
HERA_READ_DB
)
.
filter
(
answer_id
=
answer_id
)
.
values_list
(
"tag_v4_id"
,
flat
=
True
)
return
data
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
def
get_search_new_smart_rank_score
(
self
,
answer_id
):
try
:
today
=
datetime
.
datetime
.
now
()
.
date
()
...
...
talos/models/tractate/tractate.py
View file @
3653b471
...
...
@@ -308,7 +308,6 @@ class Tractate(models.Model):
# 获取贴子标签和名称
def
get_tag
(
self
,
tag_list
):
try
:
association_tags_id_list
=
list
()
tag_list
=
TagService
.
_get_by_ids_from_cache_type
(
tag_list
)
...
...
@@ -316,31 +315,24 @@ class Tractate(models.Model):
association_tags_id_list
.
append
(
{
"id"
:
item
.
id
,
"tag_name"
:
item
.
name
,
"recommend_type"
:
item
.
recommend_type
,
"tag_type"
:
item
.
tag_type
})
return
association_tags_id_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
def
get_tag_names
(
self
,
tag_list
):
try
:
association_tags_id_list
=
list
()
tag_list
=
TagService
.
_get_by_ids_from_cache_type
(
tag_list
)
for
item
in
tag_list
:
if
int
(
item
.
recommend_type
)
!=
5
or
int
(
item
.
tag_type
)
!=
11
:
association_tags_id_list
.
append
(
item
.
name
)
return
association_tags_id_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
def
get_fresh_tag_names
(
self
,
new_tag_ids
):
try
:
from
talos.services
import
AgileTagService
tag_name_list
=
list
()
...
...
@@ -348,7 +340,6 @@ class Tractate(models.Model):
for
item
in
new_tag_ids
:
data
=
agile_tag_info_dic
.
get
(
item
,
None
)
tag_name_list
.
append
(
data
.
name
)
return
tag_name_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
...
...
@@ -356,17 +347,12 @@ class Tractate(models.Model):
def
get_tag_names_content
(
self
,
tag_list
):
try
:
association_tags_id_list
=
list
()
tag_list
=
TagService
.
_get_by_ids_from_cache_type
(
tag_list
)
for
item
in
tag_list
:
if
int
(
item
.
recommend_type
)
==
5
and
int
(
item
.
tag_type
)
==
11
:
association_tags_id_list
.
append
(
item
.
name
)
return
association_tags_id_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
...
...
@@ -388,7 +374,6 @@ class Tractate(models.Model):
create_time__lte
=
now
,
is_deleted
=
False
)
.
count
()
return
int
(
vote_num
)
+
3
*
int
(
reply_num
)
+
5
*
int
(
click_num
)
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
0
...
...
@@ -411,9 +396,7 @@ class Tractate(models.Model):
try
:
result
=
TractateReply
.
objects
.
filter
(
tractate_id
=
self
.
id
)
.
values_list
(
"create_time"
,
flat
=
True
)
.
order_by
(
"-create_time"
)
.
first
()
return
result
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
''
...
...
@@ -424,9 +407,7 @@ class Tractate(models.Model):
result
=
UserConvertService
.
get_user_info_by_user_id
(
self
.
user_id
)
if
result
.
get
(
"doctor_id"
)
and
result
.
get
(
"doctor_type"
)
==
DOCTOR_TYPE
.
OFFICER
:
is_office
=
1
return
is_office
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
0
...
...
@@ -531,6 +512,15 @@ class Tractate(models.Model):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
1
def
get_tractate_tagv4_names
(
self
,
tractate_id
):
try
:
data
=
TractateTagV4
.
objects
.
using
(
settings
.
HERA_READ_DB
)
.
filter
(
tractate_id
=
tractate_id
)
.
values_list
(
"tag_v4_id"
,
flat
=
True
)
return
data
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
class
TractateExtra
(
models
.
Model
):
"""
...
...
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