From b943dd6b08d00784589e34c25740c816b2d5ffb7 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Tue, 13 Dec 2016 10:26:37 -0800 Subject: deleting old records after storing in metrics as a cache --- system/api/analytics/init.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'system/api/analytics/init.go') 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 -- cgit v1.2.3