Added HELPDESK_FOLLOWUP_TIME_SPENT_EXCLUDE_QUEUES setting

This commit is contained in:
Sam Splunks 2024-02-14 13:36:46 +00:00
parent 7e65e3d367
commit b3cbfdbe09
3 changed files with 16 additions and 1 deletions

View File

@ -335,6 +335,14 @@ Time Tracking Options
HELPDESK_FOLLOWUP_TIME_SPENT_EXCLUDE_STATUSES = (HELPDESK_TICKET_RESOLVED_STATUS,) HELPDESK_FOLLOWUP_TIME_SPENT_EXCLUDE_STATUSES = (HELPDESK_TICKET_RESOLVED_STATUS,)
- **HELPDESK_FOLLOWUP_TIME_SPENT_EXCLUDE_QUEUES** List of ticket queues slugs to exclude from automatic follow-up 'time_spent' calculation.
**Default:** ``HELPDESK_FOLLOWUP_TIME_SPENT_EXCLUDE_QUEUES = ()``
This example will have follow-ups to ticket queue 'time-not-counting-queue' not to be counted in::
HELPDESK_FOLLOWUP_TIME_SPENT_EXCLUDE_QUEUES = ('time-not-counting-queue',)
Staff Ticket Creation Settings Staff Ticket Creation Settings
------------------------------ ------------------------------

View File

@ -1027,6 +1027,7 @@ class FollowUp(models.Model):
open_hours = helpdesk_settings.FOLLOWUP_TIME_SPENT_OPENING_HOURS open_hours = helpdesk_settings.FOLLOWUP_TIME_SPENT_OPENING_HOURS
holidays = helpdesk_settings.FOLLOWUP_TIME_SPENT_EXCLUDE_HOLIDAYS holidays = helpdesk_settings.FOLLOWUP_TIME_SPENT_EXCLUDE_HOLIDAYS
exclude_statuses = helpdesk_settings.FOLLOWUP_TIME_SPENT_EXCLUDE_STATUSES exclude_statuses = helpdesk_settings.FOLLOWUP_TIME_SPENT_EXCLUDE_STATUSES
exclude_queues = helpdesk_settings.FOLLOWUP_TIME_SPENT_EXCLUDE_QUEUES
# split time interval by days # split time interval by days
days = latest.toordinal() - earliest.toordinal() days = latest.toordinal() - earliest.toordinal()
@ -1047,7 +1048,8 @@ class FollowUp(models.Model):
end_day_time = middle_day_time.replace(hour=23, minute=59, second=59) end_day_time = middle_day_time.replace(hour=23, minute=59, second=59)
if start_day_time.strftime("%m-%d") not in holidays: if start_day_time.strftime("%m-%d") not in holidays:
if self.ticket.status not in exclude_statuses: if (self.ticket.status not in exclude_statuses and
self.ticket.queue.slug not in exclude_queues):
time_spent_seconds += daily_time_spent_calculation(start_day_time, end_day_time, open_hours) time_spent_seconds += daily_time_spent_calculation(start_day_time, end_day_time, open_hours)
return datetime.timedelta(seconds=time_spent_seconds) return datetime.timedelta(seconds=time_spent_seconds)

View File

@ -176,6 +176,11 @@ FOLLOWUP_TIME_SPENT_EXCLUDE_STATUSES = getattr(settings,
'HELPDESK_FOLLOWUP_TIME_SPENT_EXCLUDE_STATUSES', 'HELPDESK_FOLLOWUP_TIME_SPENT_EXCLUDE_STATUSES',
()) ())
# Time doesn't count for listed queues slugs
FOLLOWUP_TIME_SPENT_EXCLUDE_QUEUES = getattr(settings,
'HELPDESK_FOLLOWUP_TIME_SPENT_EXCLUDE_QUEUES',
())
############################ ############################
# options for public pages # # options for public pages #
############################ ############################