mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
AMQP: fix for parseFloat
This commit is contained in:
parent
8a783f51bd
commit
e26c06ca04
1 changed files with 5 additions and 2 deletions
|
@ -28,6 +28,7 @@ import (
|
|||
"github.com/gin-gonic/gin"
|
||||
"github.com/streadway/amqp"
|
||||
"log"
|
||||
"math"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
@ -127,7 +128,9 @@ func ConnectAMQP(uri string) error {
|
|||
var sToBeUpdated database.InfrastructureComponent
|
||||
db := database.GetDB()
|
||||
ICUUID := fmt.Sprintf("%v", payload["properties.uuid"])
|
||||
uptime := fmt.Sprintf("%v", payload["uptime"])
|
||||
uptime_s := fmt.Sprintf("%v", payload["uptime"])
|
||||
uptime, _ := strconv.ParseFloat(uptime_s, 64)
|
||||
uptime = math.Round(uptime)
|
||||
state := fmt.Sprintf("%v", payload["state"])
|
||||
var stateUpdateAt = message.Timestamp.UTC()
|
||||
|
||||
|
@ -143,7 +146,7 @@ func ConnectAMQP(uri string) error {
|
|||
err = db.Model(&sToBeUpdated).Updates(map[string]interface{}{
|
||||
//"Host": gjson.Get(content, "host"),
|
||||
//"Type": gjson.Get(content, "model"),
|
||||
"Uptime": strconv.ParseFloat(uptime, 64),
|
||||
"Uptime": uptime,
|
||||
"State": state,
|
||||
"StateUpdateAt": stateUpdateAt.Format(time.RFC1123),
|
||||
//"RawProperties": gjson.Get(content, "properties"),
|
||||
|
|
Loading…
Add table
Reference in a new issue