mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-25 01:13:31 +01:00
Moving python time_spent calculation to database aggregation
This commit is contained in:
parent
f883868361
commit
df46695bb1
@ -362,11 +362,8 @@ class Queue(models.Model):
|
|||||||
"""Return back total time spent on the ticket. This is calculated value
|
"""Return back total time spent on the ticket. This is calculated value
|
||||||
based on total sum from all FollowUps
|
based on total sum from all FollowUps
|
||||||
"""
|
"""
|
||||||
total = datetime.timedelta(0)
|
res = FollowUp.objects.filter(ticket__queue=self).aggregate(models.Sum('time_spent'))
|
||||||
for val in self.ticket_set.all():
|
return res.get('time_spent__sum', datetime.timedelta(0))
|
||||||
if val.time_spent:
|
|
||||||
total = total + val.time_spent
|
|
||||||
return total
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def time_spent_formated(self):
|
def time_spent_formated(self):
|
||||||
@ -582,11 +579,8 @@ class Ticket(models.Model):
|
|||||||
"""Return back total time spent on the ticket. This is calculated value
|
"""Return back total time spent on the ticket. This is calculated value
|
||||||
based on total sum from all FollowUps
|
based on total sum from all FollowUps
|
||||||
"""
|
"""
|
||||||
total = datetime.timedelta(0)
|
res = FollowUp.objects.filter(ticket=self).aggregate(models.Sum('time_spent'))
|
||||||
for val in self.followup_set.all():
|
return res.get('time_spent__sum', datetime.timedelta(0))
|
||||||
if val.time_spent:
|
|
||||||
total = total + val.time_spent
|
|
||||||
return total
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def time_spent_formated(self):
|
def time_spent_formated(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user