From f902c05ae661bad0745e8869718af4cdcc015e17 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Mon, 12 Dec 2016 20:15:42 -0800 Subject: checking for metric data in db first --- system/api/analytics/init.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'system/api/analytics/init.go') diff --git a/system/api/analytics/init.go b/system/api/analytics/init.go index 9a5f428..95ad8f4 100644 --- a/system/api/analytics/init.go +++ b/system/api/analytics/init.go @@ -195,15 +195,13 @@ func ChartData() (map[string]interface{}, error) { // delete the record in db if it belongs to a day already in metrics, // otherwise append it to requests to be analyzed d := time.Unix(r.Timestamp/1000, 0).Format("01/02") - for i := range dates { - if metrics[i].Date == d { - err := b.Delete(k) - if err != nil { - return err - } - } else { - requests = append(requests, r) + if m.Get([]byte(d)) != nil { + err := b.Delete(k) + if err != nil { + return err } + } else { + requests = append(requests, r) } return nil -- cgit v1.2.3