aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Hanley <felix@userspace.com.au>2020-02-21 11:28:19 +0000
committerFelix Hanley <felix@userspace.com.au>2020-02-21 11:28:19 +0000
commit788eff6c299f47adf6526946aad7bb63fffcb49f (patch)
treeee2636afc6531848e495968e5a71267ec8a1c01c
parentefe829cec040e7d6157a26bbc4096d6078171f44 (diff)
downloadsws-788eff6c299f47adf6526946aad7bb63fffcb49f.tar.gz
sws-788eff6c299f47adf6526946aad7bb63fffcb49f.tar.bz2
Truncate all times to the hour
-rw-r--r--cmd/server/helpers.go6
-rw-r--r--cmd/server/sites.go3
-rw-r--r--page.go2
-rw-r--r--page_set.go3
4 files changed, 3 insertions, 11 deletions
diff --git a/cmd/server/helpers.go b/cmd/server/helpers.go
index f3733c5..9db82cf 100644
--- a/cmd/server/helpers.go
+++ b/cmd/server/helpers.go
@@ -39,17 +39,17 @@ func httpError(w http.ResponseWriter, code int, msg string) {
}
func extractTimeRange(r *http.Request) (*time.Time, *time.Time) {
- begin := timePtr(time.Now().Round(time.Hour).Add(-168 * time.Hour))
+ begin := timePtr(time.Now().Truncate(time.Hour).Add(-168 * time.Hour))
end := timePtr(time.Now())
q := r.URL.Query()
if b := q.Get("begin"); b != "" {
if bs, err := strconv.ParseInt(b, 10, 64); err == nil {
- begin = timePtr(time.Unix(bs, 0))
+ begin = timePtr(time.Unix(bs, 0).Truncate(time.Hour))
}
}
if e := q.Get("end"); e != "" {
if es, err := strconv.ParseInt(e, 10, 64); err == nil {
- end = timePtr(time.Unix(es, 0))
+ end = timePtr(time.Unix(es, 0).Truncate(time.Hour))
}
}
return begin, end
diff --git a/cmd/server/sites.go b/cmd/server/sites.go
index 25453ef..01de666 100644
--- a/cmd/server/sites.go
+++ b/cmd/server/sites.go
@@ -1,7 +1,6 @@
package main
import (
- "fmt"
"net/http"
"time"
@@ -51,9 +50,7 @@ func handleSite(db sws.SiteStore, rndr Renderer) http.HandlerFunc {
}
hitSet := sws.NewHitSet(hits, *begin, *end, time.Hour)
- fmt.Printf("site begin: %s end: %s\n", *begin, *end)
hitSet.Fill(begin, end)
- fmt.Printf("hitset begin: %s end: %s\n", hitSet.Begin(), hitSet.End())
pageSet := sws.NewPageSet(hitSet)
uaSet := sws.NewUserAgentSet(hitSet)
diff --git a/page.go b/page.go
index 93aecab..63ffc7b 100644
--- a/page.go
+++ b/page.go
@@ -1,7 +1,6 @@
package sws
import (
- "fmt"
"sort"
"time"
)
@@ -22,7 +21,6 @@ func (p Page) YMax() int {
func (p Page) XSeries() []*bucket {
p.hitSet.Fill(nil, nil)
sort.Sort(p.hitSet)
- fmt.Printf("page begin: %s end: %s\n", p.hitSet.Begin(), p.hitSet.End())
return p.hitSet.XSeries()
}
diff --git a/page_set.go b/page_set.go
index 46c2964..f3ab745 100644
--- a/page_set.go
+++ b/page_set.go
@@ -1,7 +1,5 @@
package sws
-import "fmt"
-
type PageSet map[string]*Page
func NewPageSet(hitter Hitter) PageSet {
@@ -27,7 +25,6 @@ func NewPageSet(hitter Hitter) PageSet {
}
b := hitter.Begin()
e := hitter.End()
- fmt.Printf("new pageset begin: %s end: %s\n", b, e)
for _, p := range out {
p.hitSet.Fill(&b, &e)
}