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
钟尚武
physical
Commits
311e5668
Commit
311e5668
authored
Aug 20, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
real_time
parent
e44fb45a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
1 deletion
+64
-1
pictorial.py
trans2es/models/pictorial.py
+59
-1
topic.py
trans2es/models/topic.py
+1
-0
pictorial_transfer.py
trans2es/utils/pictorial_transfer.py
+4
-0
No files found.
trans2es/models/pictorial.py
View file @
311e5668
...
...
@@ -2,9 +2,11 @@ import datetime
from
django.db
import
models
import
logging
import
traceback
from
django.conf
import
settings
from
trans2es.models.topic
import
Reply
from
.tag
import
Tag
from
.topic
import
Topic
,
TopicBillBoard
from
.user_extra
import
UserExtra
class
PictorialFollow
(
models
.
Model
):
...
...
@@ -171,6 +173,62 @@ class Pictorial(models.Model):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
def
get_latest_real_reply_time
(
self
):
try
:
reply_query_results
=
Reply
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
pictorial_id
=
self
.
id
,
is_deleted
=
0
,
is_online
=
1
)
.
values
(
"user_id"
,
"create_time"
)
datetime_list
=
list
()
if
reply_query_results
.
count
()
>
0
:
for
reply
in
reply_query_results
:
UserExtra_results
=
UserExtra
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id
=
reply
[
'user_id'
])
.
values
(
'is_shadow'
)
if
UserExtra_results
.
count
()
>
0
:
if
not
UserExtra_results
[
0
][
'is_shadow'
]:
datetime_list
.
append
(
reply
[
'create_time'
])
else
:
datetime_list
.
append
(
reply
[
'create_time'
])
if
len
(
datetime_list
)
>
0
:
dt
=
max
(
datetime_list
)
return
datetime
.
datetime
(
dt
.
year
,
dt
.
month
,
dt
.
day
,
dt
.
hour
,
dt
.
minute
,
dt
.
second
,
tzinfo
=
datetime
.
timezone
(
datetime
.
timedelta
(
hours
=
8
)))
else
:
return
datetime
.
datetime
(
1980
,
1
,
1
,
0
,
0
,
0
,
tzinfo
=
datetime
.
timezone
(
datetime
.
timedelta
(
hours
=
8
)))
except
:
return
datetime
.
datetime
(
1980
,
1
,
1
,
0
,
0
,
0
,
tzinfo
=
datetime
.
timezone
(
datetime
.
timedelta
(
hours
=
8
)))
def
get_latest_real_topic_time
(
self
):
try
:
topic_id_list
=
list
(
PictorialTopics
.
objects
.
filter
(
pictorial_id
=
self
.
id
,
is_online
=
True
,
is_deleted
=
False
)
.
values_list
(
"topic_id"
,
flat
=
True
))
logging
.
info
(
"get topic_id_list:
%
s"
%
topic_id_list
)
topic_info
=
Topic
.
objects
.
filter
(
id__in
=
topic_id_list
)
.
values
(
"user_id"
,
"create_time"
)
logging
.
info
(
"get topic_info:
%
s"
%
topic_info
)
datetime_list
=
list
()
if
topic_info
.
count
()
>
0
:
for
topic
in
topic_info
:
UserExtra_results
=
UserExtra
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id
=
topic
[
'user_id'
])
.
values
(
'is_shadow'
)
if
UserExtra_results
.
count
()
>
0
:
if
not
UserExtra_results
[
0
][
'is_shadow'
]:
datetime_list
.
append
(
topic
[
'create_time'
])
else
:
datetime_list
.
append
(
topic
[
'create_time'
])
logging
.
info
(
"get datetime_list:
%
s"
%
datetime_list
)
if
len
(
datetime_list
)
>
0
:
dt
=
max
(
datetime_list
)
logging
.
info
(
"get max datetime_list:
%
s"
%
dt
)
return
datetime
.
datetime
(
dt
.
year
,
dt
.
month
,
dt
.
day
,
dt
.
hour
,
dt
.
minute
,
dt
.
second
,
tzinfo
=
datetime
.
timezone
(
datetime
.
timedelta
(
hours
=
8
)))
else
:
return
datetime
.
datetime
(
1980
,
1
,
1
,
0
,
0
,
0
,
tzinfo
=
datetime
.
timezone
(
datetime
.
timedelta
(
hours
=
8
)))
except
:
return
datetime
.
datetime
(
1980
,
1
,
1
,
0
,
0
,
0
,
tzinfo
=
datetime
.
timezone
(
datetime
.
timedelta
(
hours
=
8
)))
class
PictorialTag
(
models
.
Model
):
"""画报关注标签"""
...
...
trans2es/models/topic.py
View file @
311e5668
...
...
@@ -420,4 +420,5 @@ class Reply(models.Model):
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u'是否删除'
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u'是否上线'
)
pictorial_id
=
models
.
IntegerField
(
verbose_name
=
u"榜单ID"
)
trans2es/utils/pictorial_transfer.py
View file @
311e5668
...
...
@@ -70,6 +70,10 @@ class PictorialTransfer(object):
res
[
"is_cover"
]
=
instance
.
get_is_cover
(
res
[
"topic_id_list"
])
res
[
"topic_vote_number"
]
=
instance
.
get_topic_vote_number
()
res
[
"activity_join"
]
=
instance
.
get_activity_join
()
res
[
"latest_real_reply_time"
]
=
instance
.
get_latest_real_reply_time
()
res
[
"latest_real_topic_time"
]
=
instance
.
get_latest_real_topic_time
()
logging
.
info
(
"get data:
%
s"
%
res
)
return
res
except
:
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