aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Hanley <felix@userspace.com.au>2020-02-19 02:17:43 +0000
committerFelix Hanley <felix@userspace.com.au>2020-02-19 02:17:43 +0000
commit7347709f62b5adeaf5f6e3aca694dab551acdc99 (patch)
treedbeec8a1334a0c5837dac01d4e55834606fa0839
parentee02835f27fc7bd222a34d86cafbd723b05946c0 (diff)
downloadsws-7347709f62b5adeaf5f6e3aca694dab551acdc99.tar.gz
sws-7347709f62b5adeaf5f6e3aca694dab551acdc99.tar.bz2
Fix time buckets to truncate and time query params to round
-rw-r--r--cmd/server/helpers.go4
-rw-r--r--time_buckets.go2
2 files changed, 3 insertions, 3 deletions
diff --git a/cmd/server/helpers.go b/cmd/server/helpers.go
index 8321ffc..3038b91 100644
--- a/cmd/server/helpers.go
+++ b/cmd/server/helpers.go
@@ -23,7 +23,7 @@ var funcMap = template.FuncMap{
return t.Format(time.RFC3339)
},
"timeHour": func(t time.Time) string {
- return t.Format("15:04")
+ return t.Format("15:04 Jan 2")
},
"percent": func(a, b int) float64 {
return (float64(a) / float64(b)) * 100
@@ -34,7 +34,7 @@ var funcMap = template.FuncMap{
}
func extractTimeRange(r *http.Request) (*time.Time, *time.Time) {
- begin := timePtr(time.Now().Add(-24 * time.Hour))
+ begin := timePtr(time.Now().Round(time.Hour).Add(-168 * time.Hour))
end := timePtr(time.Now())
q := r.URL.Query()
if b := q.Get("begin"); b != "" {
diff --git a/time_buckets.go b/time_buckets.go
index d476ff3..f17ee38 100644
--- a/time_buckets.go
+++ b/time_buckets.go
@@ -41,7 +41,7 @@ func HitsToTimeBuckets(hits []*Hit, d time.Duration) TimeBuckets {
Buckets: make([]Bucket, 0),
}
for j, h := range hits {
- k := h.CreatedAt.Round(d)
+ k := h.CreatedAt.Truncate(d)
if j == 0 || k.Before(out.TimeMin) {
out.TimeMin = k
}