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
af2ae9c2
Commit
af2ae9c2
authored
Mar 21, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
7d3e54bf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
27 deletions
+50
-27
pictorial.py
trans2es/models/pictorial.py
+44
-22
pictorial_transfer.py
trans2es/utils/pictorial_transfer.py
+6
-5
No files found.
trans2es/models/pictorial.py
View file @
af2ae9c2
...
...
@@ -6,6 +6,7 @@ import traceback
from
.tag
import
Tag
from
.topic
import
Topic
class
PictorialFollow
(
models
.
Model
):
"""画报关注"""
...
...
@@ -23,6 +24,22 @@ class PictorialFollow(models.Model):
user_id
=
models
.
BigIntegerField
(
verbose_name
=
u'用户ID'
)
class
PictorialTopics
(
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'是否删除'
)
class
Pictorial
(
models
.
Model
):
"""画报关注"""
...
...
@@ -50,7 +67,7 @@ class Pictorial(models.Model):
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
=
PictorialTopic
.
objects
.
filter
(
pictorial_id
=
self
.
id
)
.
values_list
(
"topic_id"
,
flat
=
True
)
topic_id_list
=
PictorialTopic
s
.
objects
.
filter
(
pictorial_id
=
self
.
id
)
.
values_list
(
"topic_id"
,
flat
=
True
)
logging
.
info
(
"get topic_id_list:
%
s"
%
topic_id_list
)
...
...
@@ -65,43 +82,48 @@ class Pictorial(models.Model):
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
)
def
get_tag_by_id
(
self
):
try
:
tag_id_list
=
[]
tags
=
Tag
.
objects
.
filter
(
id
=
self
.
tag_id
)
.
values_list
(
"id"
,
flat
=
True
)
tags
=
PictorialTag
.
objects
.
filter
(
pictorial_id
=
self
.
id
,
is_online
=
True
)
.
values_list
(
"tag_id"
,
flat
=
True
)
logging
.
info
(
"get tags:
%
s"
%
tags
)
for
i
in
tags
:
tag_id_list
.
append
(
i
.
tag
)
logging
.
info
(
"get tags i:
%
s"
%
i
)
tag_id_list
.
append
(
i
.
tag_id
)
return
tag_id_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
False
def
get_tag_by_name
(
self
):
def
get_tag_by_name
(
self
,
tag_id
):
try
:
tag_name_list
=
[]
tags
=
Tag
.
objects
.
filter
(
id
=
self
.
tag_id
)
.
values_list
(
"name"
,
flat
=
True
)
tags
=
Tag
.
objects
.
filter
(
id_in
=
tag_id
,
is_online
=
True
)
.
values_list
(
"name"
,
flat
=
True
)
logging
.
info
(
"get tags name :
%
s"
%
tags
)
for
i
in
tags
:
tag_name_list
.
append
(
i
.
tag
)
tag_name_list
.
append
(
i
.
name
)
logging
.
info
(
"get tags name i:
%
s"
%
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/utils/pictorial_transfer.py
View file @
af2ae9c2
...
...
@@ -6,13 +6,14 @@ import logging
import
traceback
from
libs.tools
import
tzlc
class
PictorialTransfer
(
object
):
def
__init__
(
self
):
pass
@classmethod
def
get_poctorial_data
(
cls
,
instance
):
def
get_poctorial_data
(
cls
,
instance
):
try
:
res
=
dict
()
...
...
@@ -32,10 +33,11 @@ class PictorialTransfer(object):
tzlc_udpate_time
=
tzlc
(
update_time
)
res
[
"update_time"
]
=
tzlc_udpate_time
res
[
"high_quality_topic_num"
]
=
instance
.
get_high_quality_topic_num
()
res
[
"tag_id"
]
=
instance
.
get_tag_by_id
()
res
[
"tag_name"
]
=
instance
.
get_tag_by_name
()
tag_id
=
instance
.
get_tag_by_id
()
res
[
"tag_id"
]
=
tag_id
res
[
"tag_name"
]
=
instance
.
get_tag_by_name
(
tag_id
)
return
res
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
dict
()
\ No newline at end of file
return
dict
()
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