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
a418e677
Commit
a418e677
authored
Mar 25, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
merge huabao
parents
f8b6ccd2
34a89a76
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
367 additions
and
42 deletions
+367
-42
topic.py
search/utils/topic.py
+0
-0
business_topic.py
search/views/business_topic.py
+4
-1
group.py
search/views/group.py
+152
-25
topic.py
search/views/topic.py
+1
-0
pictorial.json
trans2es/mapping/pictorial.json
+22
-0
__init__.py
trans2es/models/__init__.py
+2
-2
pictorial.py
trans2es/models/pictorial.py
+118
-4
topic.py
trans2es/models/topic.py
+21
-8
pictorial_transfer.py
trans2es/utils/pictorial_transfer.py
+44
-0
topic_transfer.py
trans2es/utils/topic_transfer.py
+3
-2
No files found.
search/utils/topic.py
View file @
a418e677
This diff is collapsed.
Click to expand it.
search/views/business_topic.py
View file @
a418e677
...
...
@@ -18,11 +18,14 @@ def business_topic_search(filters, nfilters=None, sorts_by=None, offset=0, size=
"""帖子搜索。"""
try
:
result_list
=
TopicUtils
.
list_topic_ids
(
result_list
=
TopicUtils
.
business_topic_ids
(
filters
=
filters
,
nfilters
=
nfilters
,
sorts_by
=
sorts_by
,
offset
=
offset
,
size
=
size
,
filter_online
=
False
,
index_name
=
"topic"
)
logging
.
info
(
"get result_lsit:
%
s"
%
result_list
)
topic_ids
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_list
[
"hits"
]]
return
{
"topic_ids"
:
topic_ids
,
"total_count"
:
result_list
[
"total_count"
]}
except
:
...
...
search/views/group.py
View file @
a418e677
...
...
@@ -12,8 +12,8 @@ from search.utils.common import GroupSortTypes
from
libs.es
import
ESPerform
@bind
(
"physical/search/query_
group
"
)
def
query_
group
(
query
=
""
,
offset
=
0
,
size
=
10
):
@bind
(
"physical/search/query_
pictorial
"
)
def
query_
pictorial
(
query
=
""
,
offset
=
0
,
size
=
10
):
"""
:remark:小组搜索排序策略,缺少排序策略
:param query:
...
...
@@ -22,7 +22,7 @@ def query_group(query="",offset=0,size=10):
:return:
"""
try
:
result_dict
=
GroupUtils
.
get_group_query_result
(
query
,
offset
,
size
)
result_dict
=
GroupUtils
.
get_group_query_result
(
query
,
offset
,
size
)
group_ids_list
=
[]
if
len
(
result_dict
[
"hits"
])
>
0
:
...
...
@@ -31,10 +31,11 @@ def query_group(query="",offset=0,size=10):
return
{
"group_ids"
:
group_ids_list
}
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
"group_ids"
:[]}
return
{
"group_ids"
:
[]}
@bind
(
"physical/search/group_sort"
)
def
group_sort
(
user_id
=-
1
,
sort_type
=
GroupSortTypes
.
HOT_RECOMMEND
,
offset
=
0
,
size
=
10
):
@bind
(
"physical/search/pictorial_sort"
)
def
pictorial_sort
(
user_id
=-
1
,
sort_type
=
GroupSortTypes
.
HOT_RECOMMEND
,
offset
=
0
,
size
=
10
):
"""
:remark 小组排序,缺少:前1天发评论人数*x
:param user_id:
...
...
@@ -44,34 +45,160 @@ def group_sort(user_id=-1,sort_type=GroupSortTypes.HOT_RECOMMEND,offset=0,size=1
:return:
"""
try
:
if
not
isinstance
(
user_id
,
int
):
if
not
isinstance
(
user_id
,
int
):
user_id
=
-
1
#获取es链接对象
#
获取es链接对象
es_cli_obj
=
ESPerform
.
get_cli
()
if
sort_type
==
GroupSortTypes
.
HOT_RECOMMEND
:
group_ids_list
=
GroupUtils
.
get_hot_group_recommend_result_list
(
offset
,
size
,
es_cli_obj
)
if
sort_type
==
GroupSortTypes
.
HOT_RECOMMEND
:
pictorial_ids_list
=
GroupUtils
.
get_hot_pictorial_recommend_result_list
(
offset
,
size
,
es_cli_obj
)
return
{
"
group_recommend_ids"
:
group
_ids_list
}
return
{
"
pictorial_recommend_ids"
:
pictorial
_ids_list
}
elif
sort_type
==
GroupSortTypes
.
ATTENTION_RECOMMEND
:
attention_group_list
=
GroupUtils
.
get_user_attention_group_list
(
user_id
,
offset
=
0
,
size
=
1
,
es_cli_obj
=
es_cli_obj
)
if
len
(
attention_group_list
)
==
0
:
return
{
"group_recommend_ids"
:
[]}
elif
sort_type
==
GroupSortTypes
.
ATTENTION_RECOMMEND
:
attention_pictorial_list
=
GroupUtils
.
get_user_attention_pictorial_list
(
user_id
,
offset
=
0
,
size
=
1
,
es_cli_obj
=
es_cli_obj
)
if
len
(
attention_pictorial_list
)
==
0
:
return
{
"pictorial_recommend_ids"
:
[]}
else
:
attention_group_id_list
=
[
item
[
"group_id"
]
for
item
in
attention_group_list
]
sorted_group_ids_list
=
GroupUtils
.
get_group_ids_by_aggs
(
attention_group_id_list
,
es_cli_obj
)
attention_pictorial_id_list
=
[
item
[
"pictorial_id"
]
for
item
in
attention_pictorial_list
]
sorted_pictorial_ids_list
=
GroupUtils
.
get_pictorial_ids_by_aggs
(
attention_pictorial_id_list
,
es_cli_obj
)
pictorial_recommend_ids_list
=
sorted_pictorial_ids_list
# if len(group_recommend_ids_list) < size and len(group_recommend_ids_list)<len(attention_group_list):
sorted_attention_pictorial_list
=
sorted
(
attention_pictorial_list
,
key
=
lambda
item
:
item
[
"update_time_val"
],
reverse
=
True
)
for
item
in
sorted_attention_pictorial_list
:
if
item
[
"pictorial_id"
]
not
in
pictorial_recommend_ids_list
:
pictorial_recommend_ids_list
.
append
(
item
[
"pictorial_id"
])
return
{
"pictorial_recommend_ids"
:
pictorial_recommend_ids_list
[
offset
:(
offset
+
size
)]}
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
"pictorial_recommend_ids"
:
[]}
@bind
(
"physical/search/pictorial_topic"
)
def
pictorial_topic
(
topic_id
=-
1
,
offset
=
0
,
size
=
10
):
"""
:remark 入选画报
:param user_id:
:param sort_type:
:param offset:
:param size:
:return:
"""
try
:
if
not
isinstance
(
topic_id
,
int
):
user_id
=
-
1
# 获取es链接对象
es_cli_obj
=
ESPerform
.
get_cli
()
q
=
{}
# 获取帖子从属的画报
q
[
"query"
]
=
{
"term"
:
{
"id"
:
topic_id
}
}
q
[
"_source"
]
=
{
"includes"
:
[
"id"
,
"pictorial_id"
,
"tag_list"
]
}
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"topic"
,
q
,
offset
,
size
)
logging
.
info
(
"get result_dict:
%
s"
%
result_dict
)
pict_pictorial_ids_list
=
[]
topic_tag_list
=
[]
pictorial_id_list
=
[]
if
len
(
result_dict
[
"hits"
])
>
0
:
for
item
in
result_dict
[
"hits"
]:
pict_pictorial_ids_list
=
item
[
"_source"
][
"pictorial_id"
]
topic_tag_list
=
item
[
"_source"
][
"tag_list"
]
q
[
"query"
]
=
{
"bool"
:
{
"must"
:
[{
"terms"
:
{
"id"
:
pict_pictorial_ids_list
}
},
{
"term"
:
{
"is_online"
:
True
}
},
{
"term"
:
{
"is_deleted"
:
False
}
},
]
}
}
q
[
"_source"
]
=
{
"includes"
:
[
"id"
,
"update_time"
]
}
q
[
"sort"
]
=
{
'update_time'
:
{
'order'
:
'desc'
}
}
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"pictorial"
,
q
,
offset
,
size
)
if
len
(
result_dict
[
"hits"
])
>
0
:
for
item
in
result_dict
[
"hits"
]:
pictorial_id
=
item
[
"_source"
][
"id"
]
pictorial_id_list
.
append
(
pictorial_id
)
if
len
(
pictorial_id_list
)
<
10
:
num
=
10
-
len
(
pictorial_id_list
)
q
[
"query"
]
=
{
"bool"
:
{
"must"
:
[{
"terms"
:
{
"tag_id"
:
topic_tag_list
}},
{
"term"
:
{
"is_online"
:
True
}
},{
"term"
:
{
"is_deleted"
:
False
}
}]
}
}
q
[
"_source"
]
=
{
"includes"
:
[
"id"
,
"tag_id"
]}
q
[
"sort"
]
=
{
'update_time'
:
{
'order'
:
'desc'
}}
q
[
"from"
]
=
0
q
[
"size"
]
=
10
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"pictorial"
,
q
,
offset
,
size
)
if
len
(
result_dict
[
"hits"
])
>
0
:
for
item
in
result_dict
[
"hits"
]:
id
=
item
[
"_source"
][
"id"
]
if
id
not
in
pictorial_id_list
:
pictorial_id_list
.
append
(
id
)
#
pictorial_list
=
pictorial_id_list
if
len
(
pictorial_id_list
)
<
10
else
pictorial_id_list
[:
10
]
group_recommend_ids_list
=
sorted_group_ids_list
#if len(group_recommend_ids_list) < size and len(group_recommend_ids_list)<len(attention_group_list):
sorted_attention_group_list
=
sorted
(
attention_group_list
,
key
=
lambda
item
:
item
[
"update_time_val"
],
reverse
=
True
)
for
item
in
sorted_attention_group_list
:
if
item
[
"group_id"
]
not
in
group_recommend_ids_list
:
group_recommend_ids_list
.
append
(
item
[
"group_id"
])
return
{
"pictorial_ids_list"
:
pictorial_list
}
return
{
"group_recommend_ids"
:
group_recommend_ids_list
[
offset
:(
offset
+
size
)]}
else
:
return
{
"pictorial_ids_list"
:
pictorial_id_list
}
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
"
group_recommend_ids"
:
[]}
return
{
"
pictorial_ids_list"
:
[]}
search/views/topic.py
View file @
a418e677
...
...
@@ -324,6 +324,7 @@ def topic_search(filters, nfilters=None, sorts_by=None, offset=0, size=10):
try
:
result_list
=
TopicUtils
.
list_topic_ids
(
filters
=
filters
,
nfilters
=
nfilters
,
sorts_by
=
sorts_by
,
offset
=
offset
,
size
=
size
)
logging
.
info
(
"get result_list:
%
s"
%
result_list
)
topic_ids
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_list
[
"hits"
]]
return
{
"topic_ids"
:
topic_ids
,
...
...
trans2es/mapping/pictorial.json
0 → 100644
View file @
a418e677
{
"dynamic"
:
"strict"
,
"properties"
:
{
"id"
:{
"type"
:
"long"
},
"is_online"
:{
"type"
:
"boolean"
},
//上线
"is_deleted"
:{
"type"
:
"boolean"
},
"is_recommend"
:{
"type"
:
"boolean"
},
"name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"description"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"topic_num"
:{
"type"
:
"long"
},
"creator_id"
:{
"type"
:
"long"
},
"icon"
:{
"type"
:
"text"
},
"high_quality_topic_num"
:{
"type"
:
"long"
},
//前一天该小组
4
&
5
星帖子数量
"create_time"
:{
"type"
:
"date"
,
"format"
:
"date_time_no_millis"
},
"update_time"
:{
"type"
:
"date"
,
"format"
:
"date_time_no_millis"
},
"tag_id"
:{
"type"
:
"long"
},
"tag_name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"topic_id_list"
:{
"type"
:
"long"
}
}
}
\ No newline at end of file
trans2es/models/__init__.py
View file @
a418e677
...
...
@@ -12,5 +12,5 @@ from .tag import AccountUserTag
from
.user
import
User
from
.group
import
Group
from
.
topic
import
Topic
# from .pictorial import PictorialTopic
from
.
pictorial
import
PictorialFollow
from
.pictorial
import
Pictorial
trans2es/models/pictorial.py
View file @
a418e677
import
datetime
from
django.db
import
models
import
logging
import
traceback
from
.tag
import
Tag
from
.topic
import
Topic
class
PictorialFollow
(
models
.
Model
):
"""画报关注"""
class
Meta
:
verbose_name
=
u"画报用户关系"
app_label
=
"community"
db_table
=
"community_pictorial_follow"
id
=
models
.
IntegerField
(
verbose_name
=
u'关注ID'
,
primary_key
=
True
)
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
is_online
=
models
.
BooleanField
(
verbose_name
=
u'是否上线'
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u'是否删除'
)
pictorial_id
=
models
.
BigIntegerField
(
verbose_name
=
u'画报ID'
)
user_id
=
models
.
BigIntegerField
(
verbose_name
=
u'用户ID'
)
class
PictorialTopic
(
models
.
Model
):
class
PictorialTopic
s
(
models
.
Model
):
"""画报帖子关系"""
class
Meta
:
...
...
@@ -11,9 +32,102 @@ class PictorialTopic(models.Model):
app_label
=
'community'
db_table
=
'community_pictorial_topic'
id
=
models
.
IntegerField
(
verbose_name
=
u'日记ID'
,
primary_key
=
True
)
pictorial_id
=
models
.
BigIntegerField
(
verbose_name
=
u'画报ID'
)
topic_id
=
models
.
BigIntegerField
(
verbose_name
=
u'帖子ID'
)
is_online
=
models
.
BooleanField
(
verbose_name
=
'是否上线'
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
'是否删除'
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u"是否有效"
,
default
=
True
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u'是否上线'
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u'是否删除'
)
class
Pictorial
(
models
.
Model
):
"""画报关注"""
class
Meta
:
verbose_name
=
u"画报"
app_label
=
"community"
db_table
=
"community_pictorial"
id
=
models
.
IntegerField
(
verbose_name
=
u'关注ID'
,
primary_key
=
True
)
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
is_online
=
models
.
BooleanField
(
verbose_name
=
u'是否上线'
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u'是否删除'
)
is_recommend
=
models
.
BooleanField
(
verbose_name
=
u'推荐'
)
name
=
models
.
CharField
(
verbose_name
=
u'画报名称'
,
max_length
=
100
)
description
=
models
.
CharField
(
verbose_name
=
u'画报描述'
,
max_length
=
200
)
creator_id
=
models
.
BigIntegerField
(
verbose_name
=
u'画报用户ID'
)
icon
=
models
.
CharField
(
verbose_name
=
u'画报名称'
,
max_length
=
255
)
topic_num
=
models
.
IntegerField
(
verbose_name
=
u'次数'
)
def
get_topic_id
(
self
):
try
:
topic_id
=
[]
topic_id_list
=
PictorialTopics
.
objects
.
filter
(
pictorial_id
=
self
.
id
)
.
values_list
(
"topic_id"
,
flat
=
True
)
for
i
in
topic_id_list
:
topic_id
.
append
(
i
)
return
topic_id
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
False
# 获取前一天4,5星发帖数
def
get_high_quality_topic_num
(
self
):
try
:
yesterday
=
datetime
.
datetime
.
now
()
-
datetime
.
timedelta
(
days
=
1
)
yesterday_begin_time
=
"
%
s-
%
s-
%
s 00:00:00"
%
(
yesterday
.
year
,
yesterday
.
month
,
yesterday
.
day
)
yesterday_end_time
=
"
%
s-
%
s-
%
s 23:59:59"
%
(
yesterday
.
year
,
yesterday
.
month
,
yesterday
.
day
)
topic_id_list
=
PictorialTopics
.
objects
.
filter
(
pictorial_id
=
self
.
id
)
.
values_list
(
"topic_id"
,
flat
=
True
)
topic_num
=
Topic
.
objects
.
filter
(
content_level__in
=
[
"4"
,
"5"
],
create_time__gte
=
yesterday_begin_time
,
create_time__lte
=
yesterday_end_time
,
id__in
=
topic_id_list
)
.
count
()
return
topic_num
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
False
def
get_tag_by_id
(
self
):
try
:
tag_id_list
=
[]
tags
=
PictorialTag
.
objects
.
filter
(
pictorial_id
=
self
.
id
,
is_online
=
True
)
.
values_list
(
"tag_id"
,
flat
=
True
)
for
i
in
tags
:
tag_id_list
.
append
(
i
)
return
tag_id_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
False
def
get_tag_by_name
(
self
,
tag_id
):
try
:
tag_name_list
=
[]
tags
=
Tag
.
objects
.
filter
(
id__in
=
tag_id
,
is_online
=
True
)
.
values_list
(
"name"
,
flat
=
True
)
for
i
in
tags
:
tag_name_list
.
append
(
i
)
return
tag_name_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
False
class
PictorialTag
(
models
.
Model
):
"""画报关注标签"""
class
Meta
:
verbose_name
=
u"画报标签"
app_label
=
"community"
db_table
=
"community_pictorial_tag"
id
=
models
.
IntegerField
(
verbose_name
=
u'关注ID'
,
primary_key
=
True
)
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
pictorial_id
=
models
.
BigIntegerField
(
verbose_name
=
u'画报ID'
,
max_length
=
20
)
tag_id
=
models
.
BigIntegerField
(
verbose_name
=
u'标签ID'
,
max_length
=
20
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u'是否上线'
,
max_length
=
1
)
trans2es/models/topic.py
View file @
a418e677
...
...
@@ -16,8 +16,6 @@ from .pick_topic import PickTopic
from
.tag
import
TopicTag
,
Tag
from
.user_extra
import
UserExtra
from
.group
import
Group
from
.pictorial
import
PictorialTopic
class
ActionSumAboutTopic
(
models
.
Model
):
class
Meta
:
...
...
@@ -87,9 +85,10 @@ class Topic(models.Model):
def
get_pictorial_id
(
self
):
try
:
pictorial_id_list
=
[]
return
list
(
PictorialTopic
.
objects
.
filter
(
topic_id
=
self
.
id
,
is_online
=
True
,
is_deleted
=
False
)
.
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
:
pictorial_id_list
.
append
(
i
)
return
pictorial_id_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
...
...
@@ -153,7 +152,6 @@ class Topic(models.Model):
def
get_tag_name_list
(
self
,
tag_id_list
):
try
:
tag_name_list
=
list
()
logging
.
info
(
"get tag_id_list :
%
s"
%
tag_id_list
)
for
i
in
range
(
0
,
len
(
tag_name_list
),
1000
):
query_results
=
Tag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
id__in
=
tag_id_list
[
i
:
i
+
1000
])
for
item
in
query_results
:
...
...
@@ -223,4 +221,20 @@ class TopicComplaint(models.Model):
topic
=
models
.
ForeignKey
(
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
)
\ No newline at end of file
is_online
=
models
.
BooleanField
(
verbose_name
=
u"是否有效"
,
default
=
True
)
class
PictorialTopic
(
models
.
Model
):
"""画报帖子关系"""
class
Meta
:
verbose_name
=
u'画报帖子关系'
app_label
=
'community'
db_table
=
'community_pictorial_topic'
id
=
models
.
IntegerField
(
verbose_name
=
u'日记ID'
,
primary_key
=
True
)
pictorial_id
=
models
.
BigIntegerField
(
verbose_name
=
u'画报ID'
)
topic_id
=
models
.
BigIntegerField
(
verbose_name
=
u'帖子ID'
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u"是否有效"
,
default
=
True
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u'是否上线'
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u'是否删除'
)
trans2es/utils/pictorial_transfer.py
0 → 100644
View file @
a418e677
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import
os
import
sys
import
logging
import
traceback
from
libs.tools
import
tzlc
class
PictorialTransfer
(
object
):
def
__init__
(
self
):
pass
@classmethod
def
get_poctorial_data
(
cls
,
instance
):
try
:
res
=
dict
()
res
[
"id"
]
=
instance
.
id
res
[
"is_online"
]
=
instance
.
is_online
res
[
"is_deleted"
]
=
instance
.
is_deleted
res
[
"is_recommend"
]
=
instance
.
is_recommend
res
[
"name"
]
=
instance
.
name
res
[
"description"
]
=
instance
.
description
res
[
"topic_num"
]
=
instance
.
topic_num
res
[
"creator_id"
]
=
instance
.
creator_id
res
[
"icon"
]
=
instance
.
icon
create_time
=
instance
.
create_time
tzlc_create_time
=
tzlc
(
create_time
)
res
[
"create_time"
]
=
tzlc_create_time
update_time
=
instance
.
update_time
tzlc_udpate_time
=
tzlc
(
update_time
)
res
[
"update_time"
]
=
tzlc_udpate_time
res
[
"high_quality_topic_num"
]
=
instance
.
get_high_quality_topic_num
()
tag_id
=
instance
.
get_tag_by_id
()
res
[
"tag_id"
]
=
tag_id
res
[
"tag_name"
]
=
instance
.
get_tag_by_name
(
tag_id
)
res
[
"topic_id_list"
]
=
instance
.
get_topic_id
()
return
res
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
dict
()
trans2es/utils/topic_transfer.py
View file @
a418e677
...
...
@@ -36,6 +36,8 @@ class TopicTransfer(object):
res
[
"pictorial_id"
]
=
instance
.
get_pictorial_id
()
res
[
"share_num"
]
=
instance
.
share_num
begin
=
time
.
time
()
res
[
"pick_id_list"
]
=
instance
.
get_pick_id_info
()
end
=
time
.
time
()
...
...
@@ -110,4 +112,4 @@ class TopicTransfer(object):
return
res
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
None
\ No newline at end of file
return
None
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