feat: 优化cal_exp_duration_sec

This commit is contained in:
caoqianming 2024-12-11 18:16:03 +08:00
parent aadb9fdf2c
commit 6ecf61706a
1 changed files with 3 additions and 0 deletions

View File

@ -94,6 +94,9 @@ def cal_exp_duration_sec(stlogId: str='', all=False, now: datetime=None):
end_time__lte=st_end) | sf_qs.filter(start_time__lte=st_start, end_time__gte=st_end)).order_by('start_time').distinct()
SfLogExp.objects.filter(stlog=stlog).exclude(sflog__in=sf_qs).delete()
for ind, sflog in enumerate(sf_qs):
if ind == 0:
stlog.sflog = sflog
stlog.save()
sflogexp, _ = SfLogExp.objects.get_or_create(stlog=stlog, sflog=sflog, defaults={
'stlog': stlog, 'sflog': sflog})
# 计算duration