Skip to content

Commit

Permalink
Merge pull request #5 from Klausdk1999/develop
Browse files Browse the repository at this point in the history
invertendo ordem e add valores
  • Loading branch information
cissavgonc authored Dec 6, 2023
2 parents fbaf72c + c2b3e60 commit 2690064
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions readings_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"encoding/json"
"fmt"
"net/http"
"strconv"

Expand All @@ -24,7 +25,7 @@ func getAllReadings(w http.ResponseWriter, r *http.Request) {
db := OpenConnection()
defer db.Close()

rows, err := db.Query("SELECT id, userid, timestamp, value, torquevalues, motionwastes, setvalue FROM readings")
rows, err := db.Query("SELECT id, userid, timestamp, value, torquevalues, motionwastes, setvalue, asmtimes FROM readings")
if err != nil {
http.Error(w, "Database query error", http.StatusInternalServerError)
return
Expand All @@ -34,11 +35,11 @@ func getAllReadings(w http.ResponseWriter, r *http.Request) {
var readings []Reading
for rows.Next() {
var reading Reading
err := rows.Scan(&reading.ID, &reading.UserID, &reading.Timestamp, &reading.Value, pq.Array(&reading.TorqueValues), pq.Array(&reading.AsmTimes), pq.Array(&reading.MotionWastes), &reading.SetValue)
err := rows.Scan(&reading.ID, &reading.UserID, &reading.Timestamp, &reading.Value, pq.Array(&reading.TorqueValues), pq.Array(&reading.MotionWastes), &reading.SetValue, pq.Array(&reading.AsmTimes))

if err != nil {
http.Error(w, "Error scanning readings", http.StatusInternalServerError)
return
http.Error(w, fmt.Sprintf("Error scanning readings: %v", err), http.StatusInternalServerError)
return
}
readings = append(readings, reading)
}
Expand Down

0 comments on commit 2690064

Please sign in to comment.