mirror of https://github.com/jumpserver/jumpserver
fix: 修复因事务提交问题造成的任务无法执行和任务历史无法查看 (#9493)
Co-authored-by: Aaron3S <chenyang@fit2cloud.com>pull/9495/head
parent
1b1ae1145c
commit
3c891ec313
|
@ -1,4 +1,5 @@
|
|||
from django.db.models import Count
|
||||
from django.db.transaction import atomic
|
||||
from rest_framework.views import APIView
|
||||
from django.shortcuts import get_object_or_404
|
||||
from rest_framework.response import Response
|
||||
|
@ -66,6 +67,7 @@ class JobExecutionViewSet(OrgBulkModelViewSet):
|
|||
model = JobExecution
|
||||
search_fields = ('material',)
|
||||
|
||||
@atomic
|
||||
def perform_create(self, serializer):
|
||||
instance = serializer.save()
|
||||
instance.job_version = instance.job.version
|
||||
|
|
|
@ -235,6 +235,8 @@ class JobExecution(JMSOrgBaseModel):
|
|||
|
||||
@property
|
||||
def time_cost(self):
|
||||
if not self.date_start:
|
||||
return 0
|
||||
if self.is_finished:
|
||||
return (self.date_finished - self.date_start).total_seconds()
|
||||
return (timezone.now() - self.date_start).total_seconds()
|
||||
|
|
Loading…
Reference in New Issue