diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-12-13 08:25:29 -0800 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-12-13 08:25:29 -0800 |
commit | e73f2d30b2a1a56a7aa629b6ffcd0b1d50bd91d9 (patch) | |
tree | 91b3248cd02ecb21b5e112d28c4dfa4439cd8988 /system/api/analytics | |
parent | ff66f6e8a6b7fd5e24f9cb900ddf55e0e495c49d (diff) |
removing debug prints and adding a check for data cached or needs analysis
Diffstat (limited to 'system/api/analytics')
-rw-r--r-- | system/api/analytics/init.go | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/system/api/analytics/init.go b/system/api/analytics/init.go index 01950ee..0b24825 100644 --- a/system/api/analytics/init.go +++ b/system/api/analytics/init.go @@ -5,7 +5,6 @@ package analytics import ( "encoding/json" - "fmt" "log" "net/http" "runtime" @@ -183,8 +182,6 @@ func ChartData() (map[string]interface{}, error) { } } - fmt.Println(metrics) - return nil }) if err != nil { @@ -199,15 +196,10 @@ func ChartData() (map[string]interface{}, error) { return nil } - // 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") - if m.Get([]byte(d)) != nil { - err := b.Delete(k) - if err != nil { - return err - } - } else { + // append request to requests for analysis if its timestamp is today + // or its day is not already in cache + d := time.Unix(r.Timestamp/1000, 0) + if !d.Before(today) || m.Get([]byte(d.Format("01/02"))) != nil { requests = append(requests, r) } |