From b29cb878683f79e0d7e2dd50ec5bc3f20fe50956 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Fri, 5 Jun 2020 13:35:38 +0530 Subject: [PATCH] refactor: setting avg_response_time moved to communication --- erpnext/support/doctype/issue/issue.py | 23 ------------------- .../service_level_priority.json | 22 +++++++++++++----- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/erpnext/support/doctype/issue/issue.py b/erpnext/support/doctype/issue/issue.py index c09c729c5c..ac700c91e7 100644 --- a/erpnext/support/doctype/issue/issue.py +++ b/erpnext/support/doctype/issue/issue.py @@ -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 diff --git a/erpnext/support/doctype/service_level_priority/service_level_priority.json b/erpnext/support/doctype/service_level_priority/service_level_priority.json index 6377d1a962..3995d1e248 100644 --- a/erpnext/support/doctype/service_level_priority/service_level_priority.json +++ b/erpnext/support/doctype/service_level_priority/service_level_priority.json @@ -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",