Skip to content

Commit

Permalink
Cleaned up some code
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindhagberg committed Feb 6, 2018
1 parent 36f1850 commit ea8147c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion server/web/browse.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Hostinfo struct {
Kernel sql.NullString
Lastseen pq.NullTime
OS sql.NullString
OSEdition sql.NullString
OSEdition sql.NullString
Vendor sql.NullString
Model sql.NullString
Serialno sql.NullString
Expand Down
14 changes: 10 additions & 4 deletions server/web/frontpage.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ func frontpage(w http.ResponseWriter, req *http.Request) {

if req.FormValue("approve") != "" {
approved := req.FormValue("approve") == "1"
res, err := db.Exec("UPDATE waiting_for_approval SET approved=$1 "+
var res sql.Result
res, err = db.Exec("UPDATE waiting_for_approval SET approved=$1 "+
"WHERE hostname=$2 AND ipaddr=$3",
approved,
req.FormValue("h"),
Expand All @@ -60,7 +61,8 @@ func frontpage(w http.ResponseWriter, req *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
rows, err := res.RowsAffected()
var rows int64
rows, err = res.RowsAffected()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
Expand Down Expand Up @@ -91,7 +93,9 @@ func frontpage(w http.ResponseWriter, req *http.Request) {
if err != nil {
http.Error(w, "1: "+err.Error(), http.StatusInternalServerError)
return
} else {
}

{
defer rows.Close()
for rows.Next() {
var hostname sql.NullString
Expand Down Expand Up @@ -123,7 +127,9 @@ func frontpage(w http.ResponseWriter, req *http.Request) {
if err != nil {
http.Error(w, "1: "+err.Error(), http.StatusInternalServerError)
return
} else {
}

{
defer rows.Close()
for rows.Next() {
var app waitingForApproval
Expand Down

0 comments on commit ea8147c

Please sign in to comment.