[report] minutes to first response for issues
diff --git a/erpnext/config/support.py b/erpnext/config/support.py
index ca97164..98fa595 100644
--- a/erpnext/config/support.py
+++ b/erpnext/config/support.py
@@ -64,6 +64,12 @@
"label": _("Support Analytics"),
"icon": "icon-bar-chart"
},
+ {
+ "type": "report",
+ "name": "Minutes to First Response for Issues",
+ "doctype": "Issue",
+ "is_query_report": True
+ },
]
},
]
diff --git a/erpnext/support/report/minutes_to_first_response_for_issues/__init__.py b/erpnext/support/report/minutes_to_first_response_for_issues/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/support/report/minutes_to_first_response_for_issues/__init__.py
diff --git a/erpnext/support/report/minutes_to_first_response_for_issues/minutes_to_first_response_for_issues.js b/erpnext/support/report/minutes_to_first_response_for_issues/minutes_to_first_response_for_issues.js
new file mode 100644
index 0000000..913a7e2
--- /dev/null
+++ b/erpnext/support/report/minutes_to_first_response_for_issues/minutes_to_first_response_for_issues.js
@@ -0,0 +1,31 @@
+frappe.query_reports["Minutes to First Response for Issues"] = {
+ "filters": [
+ {
+ "fieldname":"from_date",
+ "label": __("From Date"),
+ "fieldtype": "Date",
+ 'reqd': 1,
+ "default": frappe.datetime.add_days(frappe.datetime.nowdate(), -30)
+ },
+ {
+ "fieldname":"to_date",
+ "label": __("To Date"),
+ "fieldtype": "Date",
+ 'reqd': 1,
+ "default":frappe.datetime.nowdate()
+ },
+ ],
+ get_chart_data: function(columns, result) {
+ console.log(result);
+ return {
+ data: {
+ x: 'Date',
+ columns: [
+ ['Date'].concat($.map(result, function(d) { return d[0]; })),
+ ['Mins to first reponse'].concat($.map(result, function(d) { return d[1]; }))
+ ]
+ },
+ chart_type: 'line'
+ }
+ }
+}
diff --git a/erpnext/support/report/minutes_to_first_response_for_issues/minutes_to_first_response_for_issues.json b/erpnext/support/report/minutes_to_first_response_for_issues/minutes_to_first_response_for_issues.json
new file mode 100644
index 0000000..e6dc383
--- /dev/null
+++ b/erpnext/support/report/minutes_to_first_response_for_issues/minutes_to_first_response_for_issues.json
@@ -0,0 +1,19 @@
+{
+ "add_total_row": 0,
+ "apply_user_permissions": 1,
+ "creation": "2016-06-14 17:44:26.034112",
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "idx": 0,
+ "is_standard": "Yes",
+ "modified": "2016-06-14 17:50:28.082090",
+ "modified_by": "Administrator",
+ "module": "Support",
+ "name": "Minutes to First Response for Issues",
+ "owner": "Administrator",
+ "query": "select date(creation) as creation_date, avg(mins_to_first_response) from tabIssue where creation > '2016-05-01' group by date(creation) order by creation_date;",
+ "ref_doctype": "Issue",
+ "report_name": "Minutes to First Response for Issues",
+ "report_type": "Script Report"
+}
\ No newline at end of file
diff --git a/erpnext/support/report/minutes_to_first_response_for_issues/minutes_to_first_response_for_issues.py b/erpnext/support/report/minutes_to_first_response_for_issues/minutes_to_first_response_for_issues.py
new file mode 100644
index 0000000..91f2a7a
--- /dev/null
+++ b/erpnext/support/report/minutes_to_first_response_for_issues/minutes_to_first_response_for_issues.py
@@ -0,0 +1,26 @@
+# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute(filters=None):
+ columns = [
+ {
+ 'fieldname': 'creation_date',
+ 'label': 'Date',
+ 'fieldtype': 'Date'
+ },
+ {
+ 'fieldname': 'mins',
+ 'label': 'Float',
+ 'fieldtype': 'Mins to First Response'
+ },
+ ]
+
+ data = frappe.db.sql('''select date(creation) as creation_date,
+ avg(mins_to_first_response) as mins
+ from tabIssue where date(creation) between %s and %s
+ group by creation_date order by creation_date desc''', (filters.from_date, filters.to_date))
+
+ return columns, data