mirror of
https://github.com/Luzifer/mondash.git
synced 2024-11-10 00:20:02 +00:00
Do not show expired metrics
This commit is contained in:
parent
20d26087c5
commit
dd8ce13eaf
1 changed files with 11 additions and 2 deletions
13
main.go
13
main.go
|
@ -60,10 +60,19 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dash = &Dashboard{APIKey: generateAPIKey(), Metrics: DashboardMetrics{}}
|
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{
|
renderTemplate("dashboard.html", pongo2.Context{
|
||||||
"dashid": params["dashid"],
|
"dashid": params["dashid"],
|
||||||
"metrics": dash.Metrics,
|
"metrics": metrics,
|
||||||
"apikey": dash.APIKey,
|
"apikey": dash.APIKey,
|
||||||
"baseurl": os.Getenv("BASE_URL"),
|
"baseurl": os.Getenv("BASE_URL"),
|
||||||
}, res)
|
}, res)
|
||||||
|
|
Loading…
Reference in a new issue