API /stats_top -- show only top entries for last 3 minutes
This commit is contained in:
17
helpers.go
17
helpers.go
@@ -7,6 +7,7 @@ import (
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func clamp(value, low, high int) int {
|
||||
@@ -167,6 +168,22 @@ func getClient(entry map[string]interface{}) string {
|
||||
return client
|
||||
}
|
||||
|
||||
func getTime(entry map[string]interface{}) time.Time {
|
||||
t, ok := entry["time"]
|
||||
if !ok {
|
||||
return time.Time{}
|
||||
}
|
||||
tstr, ok := t.(string)
|
||||
if !ok {
|
||||
return time.Time{}
|
||||
}
|
||||
value, err := time.Parse(time.RFC3339, tstr)
|
||||
if err != nil {
|
||||
return time.Time{}
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
// helper functions for parsing parameters from body
|
||||
// -------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user