diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-12-12 20:15:42 -0800 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-12-12 20:15:42 -0800 |
commit | f902c05ae661bad0745e8869718af4cdcc015e17 (patch) | |
tree | 08df5f050eca6abf069a8b62ef5fbb49efd246db /system/api/analytics | |
parent | adde538e9ade90ae6baba49073b9848be8e9bc56 (diff) |
checking for metric data in db first
Diffstat (limited to 'system/api/analytics')
-rw-r--r-- | system/api/analytics/init.go | 14 |
1 files changed, 6 insertions, 8 deletions
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 |