[minor] added mins to first response for opportunity

This commit is contained in:
Rushabh Mehta 2016-06-22 11:21:56 +05:30
parent a531ebea8a
commit 4cf914d902
8 changed files with 120 additions and 23 deletions

View File

@ -38,6 +38,12 @@ def get_data():
"label": _("Sales Funnel"),
"icon": "icon-bar-chart",
},
{
"type": "report",
"name": "Minutes to First Response for Opportunity",
"doctype": "Opportunity",
"is_query_report": True
},
{
"type": "report",
"is_query_report": True,

View File

View File

@ -0,0 +1,43 @@
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.query_reports["Minutes to First Response for Opportunity"] = {
"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) {
return {
data: {
x: 'Date',
columns: [
['Date'].concat($.map(result, function(d) { return d[0]; })),
['Mins to first response'].concat($.map(result, function(d) { return d[1]; }))
]
// rows: [['Date', 'Mins to first response']].concat(result)
},
axis: {
x: {
type: 'timeseries',
tick: {
format: frappe.ui.py_date_format
}
}
},
chart_type: 'line',
}
}
}

View File

@ -0,0 +1,18 @@
{
"add_total_row": 0,
"apply_user_permissions": 0,
"creation": "2016-06-17 11:28:25.867258",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"idx": 0,
"is_standard": "Yes",
"modified": "2016-06-17 11:28:25.867258",
"modified_by": "Administrator",
"module": "CRM",
"name": "Minutes to First Response for Opportunity",
"owner": "Administrator",
"ref_doctype": "Opportunity",
"report_name": "Minutes to First Response for Opportunity",
"report_type": "Script Report"
}

View File

@ -0,0 +1,28 @@
# 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',
'fieldtype': 'Float',
'label': 'Mins to First Response'
},
]
data = frappe.db.sql('''select date(creation) as creation_date,
avg(mins_to_first_response) as mins
from tabOpportunity
where date(creation) between %s and %s
and mins_to_first_response > 0
group by creation_date order by creation_date desc''', (filters.from_date, filters.to_date))
return columns, data

View File

@ -1,20 +1,20 @@
frappe.query_reports["Minutes to First Response for Issues"] = {
"filters": [
{
"fieldname":"from_date",
"label": __("From Date"),
"fieldtype": "Date",
"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",
"default": frappe.datetime.add_days(frappe.datetime.nowdate(), -30)
},
{
"fieldname":"to_date",
"label": __("To Date"),
"fieldtype": "Date",
'reqd': 1,
"default":frappe.datetime.nowdate()
},
],
"default":frappe.datetime.nowdate()
},
],
get_chart_data: function(columns, result) {
return {
data: {
@ -25,14 +25,14 @@ frappe.query_reports["Minutes to First Response for Issues"] = {
]
// rows: [['Date', 'Mins to first response']].concat(result)
},
axis: {
x: {
type: 'timeseries',
tick: {
format: '%Y-%m-%d'
}
}
},
axis: {
x: {
type: 'timeseries',
tick: {
format: frappe.ui.py_date_format
}
}
},
chart_type: 'line',
}

View File

@ -20,7 +20,9 @@ def execute(filters=None):
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
from tabIssue
where date(creation) between %s and %s
and mins_to_first_response > 0
group by creation_date order by creation_date desc''', (filters.from_date, filters.to_date))
return columns, data