add and improve remove driver function and rename datapoint
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/google/uuid"
|
||||
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||
)
|
||||
@@ -13,7 +11,7 @@ func NewUuids() *Uuids {
|
||||
return &Uuids{}
|
||||
}
|
||||
|
||||
func (u *Uuids) AddDatapoint(parentDp, newDp *Datapoint) {
|
||||
func (u *Uuids) AddDatapoint(parentDp, newDp *Datapoint) (renamed []json_dataModels.Set) {
|
||||
if odp, ok := (*u)[newDp.Uuid]; ok {
|
||||
if odp.Path == newDp.Path {
|
||||
return
|
||||
@@ -21,14 +19,14 @@ func (u *Uuids) AddDatapoint(parentDp, newDp *Datapoint) {
|
||||
newDp.Datapoints = odp.Datapoints
|
||||
newDp.HasChild = len(odp.Datapoints) > 0
|
||||
odp.Datapoints = map[string]*Datapoint{}
|
||||
newDp.RenamePaths(odp.Path)
|
||||
renamed = newDp.RenamePaths(odp.Path)
|
||||
rmDps, _ := parentDp.RemoveDatapoint(json_dataModels.Set{Path: odp.Path})
|
||||
datapoints := u.GetDatapointByPath("System:Datapoints")
|
||||
datapoints.UpdateValue(datapoints.Value.(uint64) - uint64(len(rmDps)))
|
||||
fmt.Println(11, newDp.HasChild)
|
||||
}
|
||||
|
||||
(*u)[newDp.Uuid] = newDp
|
||||
return
|
||||
}
|
||||
|
||||
func (u *Uuids) GetDatapoint(uuid uuid.UUID) *Datapoint {
|
||||
|
Reference in New Issue
Block a user