1
0
Fork 0
mirror of https://github.com/Luzifer/mondash.git synced 2024-12-22 20:11:18 +00:00

Do not show expired metrics

This commit is contained in:
Knut Ahlers 2015-02-08 09:16:32 +01:00
parent 20d26087c5
commit dd8ce13eaf

13
main.go
View file

@ -60,10 +60,19 @@ func main() {
if err != nil {
dash = &Dashboard{APIKey: generateAPIKey(), Metrics: DashboardMetrics{}}
}
sort.Sort(sort.Reverse(DashboardMetrics(dash.Metrics)))
// Filter out expired metrics
metrics := DashboardMetrics{}
for _, m := range dash.Metrics {
if m.Meta.LastUpdate.After(time.Now().Add(time.Duration(m.Expires*-1) * time.Second)) {
metrics = append(metrics, m)
}
}
sort.Sort(sort.Reverse(DashboardMetrics(metrics)))
renderTemplate("dashboard.html", pongo2.Context{
"dashid": params["dashid"],
"metrics": dash.Metrics,
"metrics": metrics,
"apikey": dash.APIKey,
"baseurl": os.Getenv("BASE_URL"),
}, res)