From f0d21263e6db33f6ca14234b2154340ef33d4764 Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Thu, 14 Feb 2019 06:14:41 +0100 Subject: [PATCH] Check types before converting numerics in CRM report builder --- crm/repository/record_report_builder.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crm/repository/record_report_builder.go b/crm/repository/record_report_builder.go index 43e152490..8a2be4ea9 100644 --- a/crm/repository/record_report_builder.go +++ b/crm/repository/record_report_builder.go @@ -164,8 +164,11 @@ func (b recordReportBuilder) Cast(row sqlx.ColScanner) map[string]interface{} { } // Cast all metrics to float64 - for _, numeric := range b.numerics { - out[numeric], _ = strconv.ParseFloat(out[numeric].(string), 64) + for _, fname := range b.numerics { + switch num := out[fname].(type) { + case string: + out[fname], _ = strconv.ParseFloat(num, 64) + } } return out