summaryrefslogtreecommitdiff
path: root/system/api/analytics/init.go
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2016-12-13 10:26:37 -0800
committerSteve Manuel <nilslice@gmail.com>2016-12-13 10:26:37 -0800
commitb943dd6b08d00784589e34c25740c816b2d5ffb7 (patch)
treedfa53650dab9be2e4235353d2714b4b1ce7b2063 /system/api/analytics/init.go
parent1cae6f9095e0477becb072d0d2a8cf956e955f56 (diff)
deleting old records after storing in metrics as a cache
Diffstat (limited to 'system/api/analytics/init.go')
-rw-r--r--system/api/analytics/init.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/system/api/analytics/init.go b/system/api/analytics/init.go
index 6c66007..8117f2a 100644
--- a/system/api/analytics/init.go
+++ b/system/api/analytics/init.go
@@ -192,11 +192,16 @@ func ChartData() (map[string]interface{}, error) {
}
// append request to requests for analysis if its timestamp is today
- // or if its day is not already in cache
+ // or if its day is not already in cache, otherwise delete it
d := time.Unix(r.Timestamp/1000, 0)
_, inCache := currentMetrics[d.Format("01/02")]
if !d.Before(today) || !inCache {
requests = append(requests, r)
+ } else {
+ err := b.Delete(k)
+ if err != nil {
+ return err
+ }
}
return nil