monfront - fix group order
The adding of the order by clause happend in the wrong position and therefore made the resultset unuseable.
This commit is contained in:
parent
73c7353082
commit
f804446ad3
@ -331,6 +331,13 @@ func showGroups(w http.ResponseWriter, r *http.Request) {
|
|||||||
if strings.HasPrefix(r.URL.Path, "/unhandled") {
|
if strings.HasPrefix(r.URL.Path, "/unhandled") {
|
||||||
query += ` and state > 0`
|
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)
|
rows, err := DB.Query(query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
@ -339,12 +346,6 @@ func showGroups(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
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{}
|
groups := []group{}
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
g := group{}
|
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,
|
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,
|
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
|
from checks c
|
||||||
join active_checks ac on c.id = ac.check_id
|
join active_checks ac on c.id = ac.check_id
|
||||||
join nodes n on c.node_id = n.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,
|
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.MappingId, &cd.MappingName, &cd.NodeId, &cd.NodeName, &cd.NodeMessage,
|
||||||
&cd.CommandId, &cd.CommandName, &cd.CommandMessage,
|
&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 {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
w.Write([]byte("problems with the database"))
|
w.Write([]byte("problems with the database"))
|
||||||
|
Loading…
Reference in New Issue
Block a user