diff options
author | Gibheer <gibheer+git@zero-knowledge.org> | 2019-01-10 09:50:18 +0100 |
---|---|---|
committer | Gibheer <gibheer+git@zero-knowledge.org> | 2019-01-10 09:50:18 +0100 |
commit | f804446ad3e2e653ffd6ef00a662d91ab79bc0dd (patch) | |
tree | 5b1849b1d1a4140b7c9b1c07713a6da8ca45445d /cmd/monfront | |
parent | 73c735308242ab9d47227b6b64bf0fff393f756c (diff) |
monfront - fix group order
The adding of the order by clause happend in the wrong position and
therefore made the resultset unuseable.
Diffstat (limited to 'cmd/monfront')
-rw-r--r-- | cmd/monfront/main.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/cmd/monfront/main.go b/cmd/monfront/main.go index f7bdaa4..e600a9e 100644 --- a/cmd/monfront/main.go +++ b/cmd/monfront/main.go @@ -331,6 +331,13 @@ func showGroups(w http.ResponseWriter, r *http.Request) { if strings.HasPrefix(r.URL.Path, "/unhandled") { query += ` and state > 0` } + + if strings.HasPrefix(r.URL.Path, "/unhandled") { + query += ` order by state desc, groupname, nodename` + } else { + query += ` order by groupname, nodename` + } + rows, err := DB.Query(query) if err != nil { w.WriteHeader(http.StatusInternalServerError) @@ -339,12 +346,6 @@ func showGroups(w http.ResponseWriter, r *http.Request) { return } - if strings.HasPrefix(r.URL.Path, "/unhandled") { - query += ` order by maxstate desc, g.name, n.name` - } else { - query += ` order by g.name, n.name` - } - groups := []group{} for rows.Next() { g := group{} @@ -388,7 +389,7 @@ func showCheck(w http.ResponseWriter, r *http.Request) { } query := `select c.id, c.message, c.enabled, c.updated, c.last_refresh, m.id, m.name, n.id, n.name, n.message, co.id, co.Name, co.message, - ac.cmdline, ac.states, ac.msg + ac.cmdline, ac.states, ac.msg, ac.next_time from checks c join active_checks ac on c.id = ac.check_id join nodes n on c.node_id = n.id @@ -398,7 +399,7 @@ func showCheck(w http.ResponseWriter, r *http.Request) { err := DB.QueryRow(query, id[0]).Scan(&cd.Id, &cd.Message, &cd.Enabled, &cd.Updated, &cd.LastRefresh, &cd.MappingId, &cd.MappingName, &cd.NodeId, &cd.NodeName, &cd.NodeMessage, &cd.CommandId, &cd.CommandName, &cd.CommandMessage, - pq.Array(&cd.CommandLine), pq.Array(&cd.States), &cd.Notice) + pq.Array(&cd.CommandLine), pq.Array(&cd.States), &cd.Notice, &cd.NextTime) if err != nil { w.WriteHeader(http.StatusInternalServerError) w.Write([]byte("problems with the database")) |