fix(dashboards): Map Chart Type Average to aggregate function AVG (#8006)

Co-authored-by: adityahase <aditya@adityahase.com>
This commit is contained in:
Anurag Mishra 2019-07-26 14:57:46 +05:30 committed by GitHub
parent d9038e3b83
commit 02e2d17d71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -45,7 +45,7 @@ def get(chart_name, from_date=None, to_date=None, refresh = None):
'''.format(
unit_function = get_unit_function(chart.based_on, timegrain),
datefield = chart.based_on,
aggregate_function = chart.chart_type,
aggregate_function = get_aggregate_function(chart.chart_type),
value_field = chart.value_based_on or '1',
doctype = chart.document_type,
conditions = conditions,
@ -67,6 +67,13 @@ def get(chart_name, from_date=None, to_date=None, refresh = None):
}]
}
def get_aggregate_function(chart_type):
return {
"Sum": "SUM",
"Count": "COUNT",
"Average": "AVG"
}[chart_type]
def convert_to_dates(data, timegrain):
result = []
for d in data: