Adding HELPDESK_FOLLOWUP_TIME_CALCULATION_EXCLUDE_STATUSES setting

This commit is contained in:
Sam Splunks 2024-02-14 13:21:19 +00:00
parent 220f6d56a8
commit 90666a47ba
3 changed files with 17 additions and 2 deletions

View File

@ -327,6 +327,14 @@ Time Tracking Options
"12-25", "12-25",
"12-31",) "12-31",)
- **HELPDESK_FOLLOWUP_TIME_CALCULATION_EXCLUDE_STATUSES** List of ticket statuses to exclude from automatic follow-up 'time_spent' calculation.
**Default:** ``HELPDESK_FOLLOWUP_TIME_CALCULATION_EXCLUDE_STATUSES = ()``
This example will have follow-ups to resolved ticket status not to be counted in::
HELPDESK_FOLLOWUP_TIME_CALCULATION_EXCLUDE_STATUSES = (HELPDESK_TICKET_RESOLVED_STATUS,)
Staff Ticket Creation Settings Staff Ticket Creation Settings
------------------------------ ------------------------------

View File

@ -1026,6 +1026,7 @@ class FollowUp(models.Model):
time_spent_seconds = 0 time_spent_seconds = 0
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_CALCULATION_EXCLUDE_STATUSES
# split time interval by days # split time interval by days
days = latest.toordinal() - earliest.toordinal() days = latest.toordinal() - earliest.toordinal()
@ -1046,6 +1047,7 @@ 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:
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

@ -167,10 +167,15 @@ FOLLOWUP_TIME_SPENT_OPENING_HOURS = getattr(settings,
{}) {})
# Holidays don't count for time_spent calculation # Holidays don't count for time_spent calculation
FOLLOWUP_TIME_SPENT_EXCLUDE_HOLIDAYS= getattr(settings, FOLLOWUP_TIME_SPENT_EXCLUDE_HOLIDAYS = getattr(settings,
'HELPDESK_FOLLOWUP_TIME_SPENT_EXCLUDE_HOLIDAYS', 'HELPDESK_FOLLOWUP_TIME_SPENT_EXCLUDE_HOLIDAYS',
()) ())
# Time doesn't count for listed ticket statuses
FOLLOWUP_TIME_CALCULATION_EXCLUDE_STATUSES = getattr(settings,
'HELPDESK_FOLLOWUP_TIME_CALCULATION_EXCLUDE_STATUSES',
())
############################ ############################
# options for public pages # # options for public pages #
############################ ############################