feat: 忽略10s内的停机

This commit is contained in:
caoqianming 2024-12-06 17:24:07 +08:00
parent 3cfc4393de
commit 152b0b5a3a
1 changed files with 6 additions and 2 deletions

View File

@ -73,8 +73,12 @@ def cal_exp_duration_sec(stlogId: str='', all=False, now: datetime=None):
now = timezone.now() now = timezone.now()
for stlog in stlogs: for stlog in stlogs:
if stlog.duration_sec is None and stlog.end_time: if stlog.duration_sec is None and stlog.end_time:
stlog.duration_sec = (stlog.end_time-stlog.start_time).total_seconds() duration_sec = (stlog.end_time-stlog.start_time).total_seconds()
stlog.save() if duration_sec <= 10:
stlog.delete()
else:
stlog.duration_sec = duration_sec
stlog.save()
is_shutdown_stlog = True is_shutdown_stlog = True
if stlog.is_shutdown is False: if stlog.is_shutdown is False:
is_shutdown_stlog = False is_shutdown_stlog = False