refactor: setting avg_response_time moved to communication
This commit is contained in:
parent
3f08350181
commit
b29cb87868
@ -64,7 +64,6 @@ class Issue(Document):
|
||||
if frappe.db.get_value("Issue", self.name, "agreement_fulfilled") == "Ongoing":
|
||||
set_service_level_agreement_variance(issue=self.name)
|
||||
self.update_agreement_status()
|
||||
set_average_response_time(issue=self)
|
||||
set_resolution_time(issue=self)
|
||||
set_user_resolution_time(issue=self)
|
||||
|
||||
@ -265,7 +264,6 @@ class Issue(Document):
|
||||
def reset_issue_metrics(self):
|
||||
self.db_set("resolution_time", None)
|
||||
self.db_set("user_resolution_time", None)
|
||||
self.db_set("avg_response_time", None)
|
||||
|
||||
|
||||
def get_priority(issue):
|
||||
@ -355,27 +353,6 @@ def set_service_level_agreement_variance(issue=None):
|
||||
if variance < 0:
|
||||
frappe.db.set_value(dt="Issue", dn=doc.name, field="agreement_fulfilled", val="Failed", update_modified=False)
|
||||
|
||||
def set_average_response_time(issue):
|
||||
# avg response time for all the responses
|
||||
communications = frappe.get_list("Communication", filters={
|
||||
"reference_doctype": issue.doctype,
|
||||
"reference_name": issue.name
|
||||
},
|
||||
fields=["sent_or_received", "name", "creation"],
|
||||
order_by="creation"
|
||||
)
|
||||
|
||||
if len(communications):
|
||||
response_times = []
|
||||
for i in range(len(communications)):
|
||||
if communications[i].sent_or_received == "Sent" and communications[i-1].sent_or_received == "Received":
|
||||
response_time = time_diff_in_seconds(communications[i].creation, communications[i-1].creation)
|
||||
if response_time > 0:
|
||||
response_times.append(response_time)
|
||||
if response_times:
|
||||
avg_response_time = sum(response_times) / len(response_times)
|
||||
issue.db_set("avg_response_time", avg_response_time)
|
||||
|
||||
|
||||
def set_resolution_time(issue):
|
||||
# total time taken from issue creation to closing
|
||||
|
@ -20,11 +20,15 @@
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Priority",
|
||||
"options": "Issue Priority"
|
||||
"options": "Issue Priority",
|
||||
"show_days": 1,
|
||||
"show_seconds": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "sb_00",
|
||||
"fieldtype": "Section Break"
|
||||
"fieldtype": "Section Break",
|
||||
"show_days": 1,
|
||||
"show_seconds": 1
|
||||
},
|
||||
{
|
||||
"columns": 2,
|
||||
@ -35,11 +39,15 @@
|
||||
},
|
||||
{
|
||||
"fieldname": "cb_00",
|
||||
"fieldtype": "Column Break"
|
||||
"fieldtype": "Column Break",
|
||||
"show_days": 1,
|
||||
"show_seconds": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "cb_01",
|
||||
"fieldtype": "Column Break"
|
||||
"fieldtype": "Column Break",
|
||||
"show_days": 1,
|
||||
"show_seconds": 1
|
||||
},
|
||||
{
|
||||
"columns": 1,
|
||||
@ -47,7 +55,9 @@
|
||||
"fieldname": "default_priority",
|
||||
"fieldtype": "Check",
|
||||
"in_list_view": 1,
|
||||
"label": "Default Priority"
|
||||
"label": "Default Priority",
|
||||
"show_days": 1,
|
||||
"show_seconds": 1
|
||||
},
|
||||
{
|
||||
"columns": 2,
|
||||
@ -59,7 +69,7 @@
|
||||
],
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2020-05-04 22:08:04.503949",
|
||||
"modified": "2020-06-05 13:08:26.428657",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Support",
|
||||
"name": "Service Level Priority",
|
||||
|
Loading…
Reference in New Issue
Block a user