mirror of https://github.com/jumpserver/jumpserver
perf: modify average_time_cost calculation in job model
parent
c088437fe5
commit
543dde57ab
|
@ -188,11 +188,7 @@ class Job(JMSOrgBaseModel, PeriodTaskModelMixin):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def average_time_cost(self):
|
def average_time_cost(self):
|
||||||
total_cost = 0
|
return self.last_execution.time_cost if self.last_execution else 0
|
||||||
finished_count = self.executions.filter(status__in=['success', 'failed']).count()
|
|
||||||
for execution in self.executions.filter(status__in=['success', 'failed']).all():
|
|
||||||
total_cost += execution.time_cost
|
|
||||||
return total_cost / finished_count if finished_count else 0
|
|
||||||
|
|
||||||
def get_register_task(self):
|
def get_register_task(self):
|
||||||
from ..tasks import run_ops_job
|
from ..tasks import run_ops_job
|
||||||
|
|
Loading…
Reference in New Issue