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
08254bef
Commit
08254bef
authored
Jun 24, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
榜单中的帖子排序
parent
f7077cdb
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
180 additions
and
51 deletions
+180
-51
topic.py
search/utils/topic.py
+49
-0
group.py
search/views/group.py
+31
-9
topic.json
trans2es/mapping/topic.json
+17
-8
topic.py
trans2es/models/topic.py
+67
-22
topic_transfer.py
trans2es/utils/topic_transfer.py
+16
-12
No files found.
search/utils/topic.py
View file @
08254bef
...
@@ -928,6 +928,35 @@ class TopicUtils(object):
...
@@ -928,6 +928,35 @@ class TopicUtils(object):
"order"
:
"desc"
"order"
:
"desc"
},
},
})
})
elif
sort_by
==
TOPIC_SEARCH_SORT
.
REAL_VOTE_AEC
:
sort_rule
.
append
({
"related_billboard.real_vote_cnt"
:
{
"order"
:
"asc"
,
"nested_path"
:
"related_billboard"
},
})
elif
sort_by
==
TOPIC_SEARCH_SORT
.
REAL_VOTE_DESC
:
sort_rule
.
append
({
"related_billboard.real_vote_cnt"
:
{
"order"
:
"desc"
,
"nested_path"
:
"related_billboard"
},
})
elif
sort_by
==
TOPIC_SEARCH_SORT
.
VIRT_VOTE_AEC
:
sort_rule
.
append
({
"related_billboard.virt_vote_cnt"
:
{
"order"
:
"asc"
,
"nested_path"
:
"related_billboard"
},
})
elif
sort_by
==
TOPIC_SEARCH_SORT
.
VIRT_VOTE_DESC
:
sort_rule
.
append
({
"related_billboard.virt_vote_cnt"
:
{
"order"
:
"desc"
,
"nested_path"
:
"related_billboard"
},
})
return
sort_rule
return
sort_rule
...
@@ -1072,6 +1101,26 @@ class TopicUtils(object):
...
@@ -1072,6 +1101,26 @@ class TopicUtils(object):
}
}
}
}
})
})
# elif k == "pictorial_id":
# f.append({
# "nested": {
# "path": "related_billboard",
# "query": {
# "bool": {
# "must": [
# {
# "term": {
# "related_billboard.pictorial_id": v
# }
# }
# ]
# }
# }
# }
# })
else
:
else
:
if
isinstance
(
v
,
list
):
if
isinstance
(
v
,
list
):
...
...
search/views/group.py
View file @
08254bef
...
@@ -105,23 +105,23 @@ def pictorial_topic(topic_id=-1, offset=0, size=10):
...
@@ -105,23 +105,23 @@ def pictorial_topic(topic_id=-1, offset=0, size=10):
q
=
{}
q
=
{}
# 获取帖子从属的画报
# 获取帖子从属的画报
q
[
"query"
]
=
{
q
[
"query"
]
=
{
"bool"
:{
"bool"
:
{
"must"
:[
"must"
:
[
{
{
"term"
:
{
"term"
:
{
"id"
:
topic_id
"id"
:
topic_id
}
}
},
},
{
{
"term"
:{
"term"
:
{
"is_online"
:
True
"is_online"
:
True
}
}
}
}
],
],
"must_not"
:[
"must_not"
:
[
{
{
"term"
:{
"term"
:
{
"is_history"
:
True
"is_history"
:
True
}
}
}
}
]
]
...
@@ -237,6 +237,7 @@ def pictorial_topic(topic_id=-1, offset=0, size=10):
...
@@ -237,6 +237,7 @@ def pictorial_topic(topic_id=-1, offset=0, size=10):
def
pictorial_topic_sort
(
pictorial_id
=-
1
,
offset
=
0
,
size
=
10
):
def
pictorial_topic_sort
(
pictorial_id
=-
1
,
offset
=
0
,
size
=
10
):
"""
"""
:remark 画报排序 人气 部分
:remark 画报排序 人气 部分
人气按照票数从大到小排序,相同票数按照图片票数更新时间由旧到新排序
:param user_id:
:param user_id:
:param sort_type:
:param sort_type:
:param offset:
:param offset:
...
@@ -251,18 +252,39 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10):
...
@@ -251,18 +252,39 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10):
"query"
:
{
"query"
:
{
"bool"
:
{
"bool"
:
{
"must"
:
[
"must"
:
[
{
"term"
:
{
"pictorial_id"
:
pictorial_id
}},
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:
{
"is_deleted"
:
False
}},
{
"term"
:
{
"is_deleted"
:
False
}},
{
"nested"
:
{
"path"
:
"related_billboard"
,
"query"
:
{
"bool"
:
{
"must"
:
[
{
"term"
:
{
"related_billboard.pictorial_id"
:
pictorial_id
}
}
]
}
}
}
}
]
]
}
}
},
},
"sort"
:
[
"sort"
:
[
{
"total_vote_num"
:
{
"order"
:
"desc"
}},
{
"related_billboard.total_vote_cnt"
:
{
"order"
:
"desc"
,
# "mode": "min",
"nested_path"
:
"related_billboard"
}},
{
"create_time"
:
{
"order"
:
"desc"
}}
{
"create_time"
:
{
"order"
:
"desc"
}}
]
]
}
}
logging
.
info
(
"get qqqqqq:
%
s"
%
q
)
pict_pictorial_ids_list
=
[]
pict_pictorial_ids_list
=
[]
# 获取es链接对象
# 获取es链接对象
es_cli_obj
=
ESPerform
.
get_cli
()
es_cli_obj
=
ESPerform
.
get_cli
()
...
...
trans2es/mapping/topic.json
View file @
08254bef
...
@@ -8,18 +8,18 @@
...
@@ -8,18 +8,18 @@
"vote_num"
:{
"type"
:
"long"
},
"vote_num"
:{
"type"
:
"long"
},
"total_vote_num"
:{
"type"
:
"long"
},
"total_vote_num"
:{
"type"
:
"long"
},
"reply_num"
:{
"type"
:
"long"
},
"reply_num"
:{
"type"
:
"long"
},
"name"
:{
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index"
,
"search_analyzer"
:
"gm_default_index
"
},
"name"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"description"
:{
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index"
,
"search_analyzer"
:
"gm_default_index
"
},
"description"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"content"
:{
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index"
,
"search_analyzer"
:
"gm_default_index
"
},
"content"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"content_level"
:{
"type"
:
"text"
},
"content_level"
:{
"type"
:
"text"
},
"user_id"
:{
"type"
:
"long"
},
"user_id"
:{
"type"
:
"long"
},
"user_nick_name"
:{
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index"
,
"search_analyzer"
:
"gm_default_index
"
},
//帖子用户名
"user_nick_name"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
//帖子用户名
"user_nick_name_pre"
:
{
"type"
:
"text"
,
"analyzer"
:
"keyword"
},
//不切词的用户名
"user_nick_name_pre"
:
{
"type"
:
"text"
,
"analyzer"
:
"keyword"
},
//不切词的用户名
"group_id"
:{
"type"
:
"long"
},
//所在组ID
"group_id"
:{
"type"
:
"long"
},
//所在组ID
"tag_list"
:{
"type"
:
"long"
},
//标签属性
"tag_list"
:{
"type"
:
"long"
},
//标签属性
"useful_tag_list"
:{
"type"
:
"long"
},
//有用标签属性
"useful_tag_list"
:{
"type"
:
"long"
},
//有用标签属性
"edit_tag_list"
:{
"type"
:
"long"
},
//编辑标签
"edit_tag_list"
:{
"type"
:
"long"
},
//编辑标签
"tag_name_list"
:{
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index"
,
"search_analyzer"
:
"gm_default_index
"
},
"tag_name_list"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"share_num"
:{
"type"
:
"long"
},
"share_num"
:{
"type"
:
"long"
},
"pick_id_list"
:{
"type"
:
"long"
},
"pick_id_list"
:{
"type"
:
"long"
},
"offline_score"
:{
"type"
:
"double"
},
//离线算分
"offline_score"
:{
"type"
:
"double"
},
//离线算分
...
@@ -50,11 +50,20 @@
...
@@ -50,11 +50,20 @@
"pictorial_id"
:{
"type"
:
"long"
},
//所在组ID
"pictorial_id"
:{
"type"
:
"long"
},
//所在组ID
"pictorial_name"
:{
//
所在组名称
"pictorial_name"
:{
//
所在组名称
"type"
:
"text"
,
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index
"
,
"analyzer"
:
"
keyword
"
,
"search_analyzer"
:
"
gm_default_index
"
"search_analyzer"
:
"
keyword
"
},
},
"is_excellent"
:{
"type"
:
"long"
},
"is_excellent"
:{
"type"
:
"long"
},
"is_operation_home_recommend"
:
{
"type"
:
"boolean"
},
//是否首页运营推荐
"is_operation_home_recommend"
:
{
"type"
:
"boolean"
},
//是否首页运营推荐
"is_history"
:
{
"type"
:
"boolean"
}
//是否历史数据
"is_history"
:
{
"type"
:
"boolean"
},
//是否历史数据
"related_billboard"
:{
"type"
:
"nested"
,
"properties"
:{
"pictorial_id"
:{
"type"
:
"long"
},
"real_vote_cnt"
:{
"type"
:
"long"
},
"virt_vote_cnt"
:{
"type"
:
"long"
},
"total_vote_cnt"
:{
"type"
:
"long"
}
}
}
}
}
}
}
trans2es/models/topic.py
View file @
08254bef
...
@@ -17,6 +17,7 @@ from .tag import TopicTag, Tag
...
@@ -17,6 +17,7 @@ from .tag import TopicTag, Tag
from
.user_extra
import
UserExtra
from
.user_extra
import
UserExtra
from
.group
import
Group
from
.group
import
Group
class
ActionSumAboutTopic
(
models
.
Model
):
class
ActionSumAboutTopic
(
models
.
Model
):
class
Meta
:
class
Meta
:
verbose_name
=
u"帖子埋点数据汇总"
verbose_name
=
u"帖子埋点数据汇总"
...
@@ -43,6 +44,7 @@ class TopicImage(models.Model):
...
@@ -43,6 +44,7 @@ class TopicImage(models.Model):
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
class
ExcellentTopic
(
models
.
Model
):
class
ExcellentTopic
(
models
.
Model
):
"""优质帖子"""
"""优质帖子"""
...
@@ -51,13 +53,14 @@ class ExcellentTopic(models.Model):
...
@@ -51,13 +53,14 @@ class ExcellentTopic(models.Model):
db_table
=
"excellent_topic"
db_table
=
"excellent_topic"
id
=
models
.
IntegerField
(
verbose_name
=
u'ID'
,
primary_key
=
True
)
id
=
models
.
IntegerField
(
verbose_name
=
u'ID'
,
primary_key
=
True
)
topic_id
=
models
.
IntegerField
(
verbose_name
=
u"帖子ID"
,
db_index
=
True
)
topic_id
=
models
.
IntegerField
(
verbose_name
=
u"帖子ID"
,
db_index
=
True
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u'是否上线'
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u'是否上线'
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u'是否删除'
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u'是否删除'
)
excellent_type
=
models
.
IntegerField
(
verbose_name
=
u"优质类型"
,
db_index
=
True
)
excellent_type
=
models
.
IntegerField
(
verbose_name
=
u"优质类型"
,
db_index
=
True
)
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
class
Topic
(
models
.
Model
):
class
Topic
(
models
.
Model
):
class
Meta
:
class
Meta
:
verbose_name
=
u'日记'
verbose_name
=
u'日记'
...
@@ -109,8 +112,8 @@ class Topic(models.Model):
...
@@ -109,8 +112,8 @@ class Topic(models.Model):
def
get_pictorial_id
(
self
):
def
get_pictorial_id
(
self
):
try
:
try
:
pictorial_id_list
=
[]
pictorial_id_list
=
[]
pictorial_id
=
PictorialTopic
.
objects
.
filter
(
topic_id
=
self
.
id
)
.
values_list
(
"pictorial_id"
,
flat
=
True
)
pictorial_id
=
PictorialTopic
.
objects
.
filter
(
topic_id
=
self
.
id
)
.
values_list
(
"pictorial_id"
,
flat
=
True
)
for
i
in
pictorial_id
:
for
i
in
pictorial_id
:
pictorial_id_list
.
append
(
i
)
pictorial_id_list
.
append
(
i
)
return
pictorial_id_list
return
pictorial_id_list
...
@@ -131,14 +134,16 @@ class Topic(models.Model):
...
@@ -131,14 +134,16 @@ class Topic(models.Model):
return
False
return
False
@classmethod
@classmethod
def
get_topic_image_num
(
cls
,
topic_id
):
def
get_topic_image_num
(
cls
,
topic_id
):
"""
"""
:remark 获取指定帖子的图片数量
:remark 获取指定帖子的图片数量
:param topic_id:
:param topic_id:
:return:
:return:
"""
"""
try
:
try
:
query_list
=
list
(
TopicImage
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
topic_id
=
topic_id
,
is_deleted
=
False
,
is_online
=
True
)
.
values_list
(
"url"
,
flat
=
True
))
query_list
=
list
(
TopicImage
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
topic_id
=
topic_id
,
is_deleted
=
False
,
is_online
=
True
)
.
values_list
(
"url"
,
flat
=
True
))
return
len
(
query_list
)
return
len
(
query_list
)
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
...
@@ -148,7 +153,8 @@ class Topic(models.Model):
...
@@ -148,7 +153,8 @@ class Topic(models.Model):
try
:
try
:
has_image
=
False
has_image
=
False
query_list
=
TopicImage
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
topic_id
=
self
.
id
,
is_deleted
=
False
,
is_online
=
True
)
query_list
=
TopicImage
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
topic_id
=
self
.
id
,
is_deleted
=
False
,
is_online
=
True
)
if
len
(
query_list
)
>
0
:
if
len
(
query_list
)
>
0
:
has_image
=
True
has_image
=
True
...
@@ -174,12 +180,13 @@ class Topic(models.Model):
...
@@ -174,12 +180,13 @@ class Topic(models.Model):
topic_tag_id_list
=
list
()
topic_tag_id_list
=
list
()
edit_tag_id_list
=
list
()
edit_tag_id_list
=
list
()
tag_id_list
=
TopicTag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
topic_id
=
self
.
id
)
.
values_list
(
"tag_id"
,
flat
=
True
)
tag_id_list
=
TopicTag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
topic_id
=
self
.
id
)
.
values_list
(
"tag_id"
,
flat
=
True
)
tag_query_results
=
Tag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
id__in
=
tag_id_list
)
tag_query_results
=
Tag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
id__in
=
tag_id_list
)
for
tag_item
in
tag_query_results
:
for
tag_item
in
tag_query_results
:
is_online
=
tag_item
.
is_online
is_online
=
tag_item
.
is_online
is_deleted
=
tag_item
.
is_deleted
is_deleted
=
tag_item
.
is_deleted
collection
=
tag_item
.
collection
collection
=
tag_item
.
collection
if
is_online
and
not
is_deleted
:
if
is_online
and
not
is_deleted
:
topic_tag_id_list
.
append
(
tag_item
.
id
)
topic_tag_id_list
.
append
(
tag_item
.
id
)
...
@@ -189,12 +196,13 @@ class Topic(models.Model):
...
@@ -189,12 +196,13 @@ class Topic(models.Model):
return
(
topic_tag_id_list
,
edit_tag_id_list
)
return
(
topic_tag_id_list
,
edit_tag_id_list
)
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
([],[])
return
([],
[])
def
get_topic_useful_tag_id_list
(
self
):
def
get_topic_useful_tag_id_list
(
self
):
try
:
try
:
topic_useful_tag_id_list
=
list
()
topic_useful_tag_id_list
=
list
()
tag_id_list
=
TopicTag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
topic_id
=
self
.
id
,
is_online
=
True
,
is_body_esthetics
=
1
)
tag_id_list
=
TopicTag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
topic_id
=
self
.
id
,
is_online
=
True
,
is_body_esthetics
=
1
)
for
tag_item
in
tag_id_list
:
for
tag_item
in
tag_id_list
:
topic_useful_tag_id_list
.
append
(
tag_item
.
tag_id
)
topic_useful_tag_id_list
.
append
(
tag_item
.
tag_id
)
return
topic_useful_tag_id_list
return
topic_useful_tag_id_list
...
@@ -202,12 +210,13 @@ class Topic(models.Model):
...
@@ -202,12 +210,13 @@ class Topic(models.Model):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
return
[]
def
get_tag_name_list
(
self
,
tag_id_list
):
def
get_tag_name_list
(
self
,
tag_id_list
):
try
:
try
:
tag_name_list
=
list
()
tag_name_list
=
list
()
for
i
in
range
(
0
,
len
(
tag_id_list
),
100
):
for
i
in
range
(
0
,
len
(
tag_id_list
),
100
):
query_terms_list
=
list
(
Tag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
id__in
=
tag_id_list
[
i
:
i
+
100
],
is_online
=
True
,
is_deleted
=
False
)
.
values_list
(
"name"
,
flat
=
True
))
query_terms_list
=
list
(
Tag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
id__in
=
tag_id_list
[
i
:
i
+
100
],
is_online
=
True
,
is_deleted
=
False
)
.
values_list
(
"name"
,
flat
=
True
))
tag_name_list
.
extend
(
query_terms_list
)
tag_name_list
.
extend
(
query_terms_list
)
return
tag_name_list
return
tag_name_list
except
:
except
:
...
@@ -234,17 +243,17 @@ class Topic(models.Model):
...
@@ -234,17 +243,17 @@ class Topic(models.Model):
user_query_results
=
UserExtra
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id
=
self
.
user_id
)
user_query_results
=
UserExtra
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id
=
self
.
user_id
)
if
user_query_results
.
count
()
>
0
:
if
user_query_results
.
count
()
>
0
:
if
user_query_results
[
0
]
.
is_recommend
:
if
user_query_results
[
0
]
.
is_recommend
:
offline_score
+=
2.0
*
10
offline_score
+=
2.0
*
10
elif
user_query_results
[
0
]
.
is_shadow
:
elif
user_query_results
[
0
]
.
is_shadow
:
user_is_shadow
=
True
user_is_shadow
=
True
# 帖子等级
# 帖子等级
if
self
.
content_level
==
'5'
:
if
self
.
content_level
==
'5'
:
offline_score
+=
100.0
*
3
offline_score
+=
100.0
*
3
elif
self
.
content_level
==
'4'
:
elif
self
.
content_level
==
'4'
:
offline_score
+=
60.0
*
3
offline_score
+=
60.0
*
3
elif
self
.
content_level
==
'6'
:
elif
self
.
content_level
==
'6'
:
offline_score
+=
200.0
*
3
offline_score
+=
200.0
*
3
if
self
.
language_type
==
1
:
if
self
.
language_type
==
1
:
offline_score
+=
60.0
offline_score
+=
60.0
...
@@ -261,6 +270,27 @@ class Topic(models.Model):
...
@@ -261,6 +270,27 @@ class Topic(models.Model):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
0.0
return
0.0
def
get_related_billboard
(
self
):
try
:
related_billboard_list
=
list
()
query_results
=
TopicBillBoard
.
objects
.
filter
(
topic_id
=
self
.
id
)
for
items
in
query_results
:
total_vote_cnt
=
int
(
items
.
virt_vote_cnt
)
+
int
(
items
.
real_vote_cnt
)
related_billboard_list
.
append
({
"pictorial_id"
:
items
.
pictorial_id
,
"real_vote_cnt"
:
items
.
real_vote_cnt
,
"virt_vote_cnt"
:
items
.
virt_vote_cnt
,
"total_vote_cnt"
:
total_vote_cnt
})
logging
.
info
(
"product_brand_info"
%
related_billboard_list
)
return
related_billboard_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
class
TopicComplaint
(
models
.
Model
):
class
TopicComplaint
(
models
.
Model
):
"""帖子举报"""
"""帖子举报"""
...
@@ -273,7 +303,8 @@ class TopicComplaint(models.Model):
...
@@ -273,7 +303,8 @@ class TopicComplaint(models.Model):
id
=
models
.
IntegerField
(
verbose_name
=
'日记图片ID'
,
primary_key
=
True
)
id
=
models
.
IntegerField
(
verbose_name
=
'日记图片ID'
,
primary_key
=
True
)
user_id
=
models
.
BigIntegerField
(
verbose_name
=
u'用户ID'
,
db_index
=
True
)
user_id
=
models
.
BigIntegerField
(
verbose_name
=
u'用户ID'
,
db_index
=
True
)
topic
=
models
.
ForeignKey
(
topic
=
models
.
ForeignKey
(
Topic
,
verbose_name
=
u"关联的帖子"
,
null
=
True
,
blank
=
True
,
default
=
None
,
on_delete
=
models
.
CASCADE
,
related_name
=
'complaints'
)
Topic
,
verbose_name
=
u"关联的帖子"
,
null
=
True
,
blank
=
True
,
default
=
None
,
on_delete
=
models
.
CASCADE
,
related_name
=
'complaints'
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u"是否有效"
,
default
=
True
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u"是否有效"
,
default
=
True
)
...
@@ -302,7 +333,7 @@ class TopicExtra(models.Model):
...
@@ -302,7 +333,7 @@ class TopicExtra(models.Model):
db_table
=
'topic_extra'
db_table
=
'topic_extra'
id
=
models
.
IntegerField
(
verbose_name
=
u'ID'
,
primary_key
=
True
)
id
=
models
.
IntegerField
(
verbose_name
=
u'ID'
,
primary_key
=
True
)
topic_id
=
models
.
IntegerField
(
verbose_name
=
u"帖子ID"
,
db_index
=
True
)
topic_id
=
models
.
IntegerField
(
verbose_name
=
u"帖子ID"
,
db_index
=
True
)
virtual_vote_num
=
models
.
IntegerField
(
verbose_name
=
"帖子虚拟点赞"
)
virtual_vote_num
=
models
.
IntegerField
(
verbose_name
=
"帖子虚拟点赞"
)
...
@@ -312,7 +343,21 @@ class TopicHomeRecommend(models.Model):
...
@@ -312,7 +343,21 @@ class TopicHomeRecommend(models.Model):
class
Meta
:
class
Meta
:
verbose_name
=
"运营位帖子"
verbose_name
=
"运营位帖子"
db_table
=
"topic_home_recommend"
db_table
=
"topic_home_recommend"
id
=
models
.
IntegerField
(
verbose_name
=
u"id"
,
primary_key
=
True
)
id
=
models
.
IntegerField
(
verbose_name
=
u"id"
,
primary_key
=
True
)
topic_id
=
models
.
IntegerField
(
verbose_name
=
u"帖子ID"
)
topic_id
=
models
.
IntegerField
(
verbose_name
=
u"帖子ID"
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u'是否上线'
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u'是否上线'
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u'是否删除'
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u'是否删除'
)
class
TopicBillBoard
(
models
.
Model
):
"""榜单投票"""
class
Meta
:
verbose_name
=
"榜单投票"
db_table
=
"topic_vote_cnt"
topic_id
=
models
.
IntegerField
(
verbose_name
=
u"帖子ID"
)
pictorial_id
=
models
.
IntegerField
(
verbose_name
=
u"榜单ID"
)
real_vote_cnt
=
models
.
IntegerField
(
verbose_name
=
u"真实赞"
)
virt_vote_cnt
=
models
.
IntegerField
(
verbose_name
=
u"虚拟赞"
)
trans2es/utils/topic_transfer.py
View file @
08254bef
...
@@ -9,12 +9,13 @@ import time
...
@@ -9,12 +9,13 @@ import time
import
re
import
re
import
datetime
import
datetime
from
trans2es.models.user
import
User
from
trans2es.models.user
import
User
from
trans2es.models.topic
import
ExcellentTopic
,
TopicHomeRecommend
from
trans2es.models.topic
import
ExcellentTopic
,
TopicHomeRecommend
class
TopicTransfer
(
object
):
class
TopicTransfer
(
object
):
@classmethod
@classmethod
def
get_topic_data
(
cls
,
instance
,
is_excellect
=
False
):
def
get_topic_data
(
cls
,
instance
,
is_excellect
=
False
):
try
:
try
:
res
=
dict
()
res
=
dict
()
...
@@ -47,25 +48,24 @@ class TopicTransfer(object):
...
@@ -47,25 +48,24 @@ class TopicTransfer(object):
begin
=
time
.
time
()
begin
=
time
.
time
()
res
[
"pick_id_list"
]
=
instance
.
get_pick_id_info
()
res
[
"pick_id_list"
]
=
instance
.
get_pick_id_info
()
end
=
time
.
time
()
end
=
time
.
time
()
time0
=
(
end
-
begin
)
time0
=
(
end
-
begin
)
begin
=
time
.
time
()
begin
=
time
.
time
()
(
topic_tag_id_list
,
edit_tag_id_list
)
=
instance
.
get_topic_tag_id_list
()
(
topic_tag_id_list
,
edit_tag_id_list
)
=
instance
.
get_topic_tag_id_list
()
res
[
"tag_list"
]
=
topic_tag_id_list
res
[
"tag_list"
]
=
topic_tag_id_list
res
[
"edit_tag_list"
]
=
edit_tag_id_list
res
[
"edit_tag_list"
]
=
edit_tag_id_list
end
=
time
.
time
()
end
=
time
.
time
()
time1
=
(
end
-
begin
)
time1
=
(
end
-
begin
)
begin
=
time
.
time
()
begin
=
time
.
time
()
res
[
"tag_name_list"
]
=
instance
.
get_tag_name_list
(
res
[
"tag_list"
])
res
[
"tag_name_list"
]
=
instance
.
get_tag_name_list
(
res
[
"tag_list"
])
end
=
time
.
time
()
end
=
time
.
time
()
time2
=
(
end
-
begin
)
time2
=
(
end
-
begin
)
begin
=
time
.
time
()
begin
=
time
.
time
()
res
[
"offline_score"
]
=
instance
.
get_topic_offline_score
()
res
[
"offline_score"
]
=
instance
.
get_topic_offline_score
()
end
=
time
.
time
()
end
=
time
.
time
()
time3
=
(
end
-
begin
)
time3
=
(
end
-
begin
)
begin
=
time
.
time
()
begin
=
time
.
time
()
res
[
"manual_score"
]
=
instance
.
drop_score
res
[
"manual_score"
]
=
instance
.
drop_score
...
@@ -73,10 +73,10 @@ class TopicTransfer(object):
...
@@ -73,10 +73,10 @@ class TopicTransfer(object):
res
[
"has_video"
]
=
instance
.
has_video
res
[
"has_video"
]
=
instance
.
has_video
res
[
"language_type"
]
=
instance
.
language_type
res
[
"language_type"
]
=
instance
.
language_type
end
=
time
.
time
()
end
=
time
.
time
()
time4
=
(
end
-
begin
)
time4
=
(
end
-
begin
)
# begin = time.time()
# begin = time.time()
topic_useful_tag_id_list
=
instance
.
get_topic_useful_tag_id_list
()
topic_useful_tag_id_list
=
instance
.
get_topic_useful_tag_id_list
()
res
[
"useful_tag_list"
]
=
topic_useful_tag_id_list
res
[
"useful_tag_list"
]
=
topic_useful_tag_id_list
# end = time.time()
# end = time.time()
# time5 = (end - begin)
# time5 = (end - begin)
...
@@ -99,7 +99,7 @@ class TopicTransfer(object):
...
@@ -99,7 +99,7 @@ class TopicTransfer(object):
res
[
"virtual_content_level"
]
=
instance
.
virtual_content_level
res
[
"virtual_content_level"
]
=
instance
.
virtual_content_level
res
[
"like_num_crawl"
]
=
instance
.
like_num_crawl
res
[
"like_num_crawl"
]
=
instance
.
like_num_crawl
res
[
"comment_num_crawl"
]
=
instance
.
comment_num_crawl
res
[
"comment_num_crawl"
]
=
instance
.
comment_num_crawl
res
[
"is_crawl"
]
=
instance
.
is_crawl
res
[
"is_crawl"
]
=
instance
.
is_crawl
res
[
"platform"
]
=
instance
.
platform
res
[
"platform"
]
=
instance
.
platform
...
@@ -113,7 +113,6 @@ class TopicTransfer(object):
...
@@ -113,7 +113,6 @@ class TopicTransfer(object):
res
[
"create_time"
]
=
tzlc_create_time
res
[
"create_time"
]
=
tzlc_create_time
res
[
"create_time_val"
]
=
int
(
time
.
mktime
(
tzlc_create_time
.
timetuple
()))
res
[
"create_time_val"
]
=
int
(
time
.
mktime
(
tzlc_create_time
.
timetuple
()))
update_time
=
instance
.
update_time
update_time
=
instance
.
update_time
tzlc_update_time
=
tzlc
(
update_time
)
tzlc_update_time
=
tzlc
(
update_time
)
res
[
"update_time"
]
=
tzlc_update_time
res
[
"update_time"
]
=
tzlc_update_time
...
@@ -137,7 +136,12 @@ class TopicTransfer(object):
...
@@ -137,7 +136,12 @@ class TopicTransfer(object):
if
operation_home_recommend
and
operation_home_recommend
.
is_online
and
not
operation_home_recommend
.
is_deleted
:
if
operation_home_recommend
and
operation_home_recommend
.
is_online
and
not
operation_home_recommend
.
is_deleted
:
res
[
"is_operation_home_recommend"
]
=
True
res
[
"is_operation_home_recommend"
]
=
True
logging
.
info
(
"test topic transfer time cost,time0:
%
d,time1:
%
d,time2:
%
d,time3:
%
d,time4:
%
d"
%
(
time0
,
time1
,
time2
,
time3
,
time4
))
logging
.
info
(
"test topic transfer time cost,time0:
%
d,time1:
%
d,time2:
%
d,time3:
%
d,time4:
%
d"
%
(
time0
,
time1
,
time2
,
time3
,
time4
))
# 榜单关联的投票
res
[
"related_billboard"
]
=
instance
.
get_related_billboard
()
return
res
return
res
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
...
...
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