new json_data model

This commit is contained in:
Adrian Zuercher
2025-05-04 22:21:12 +02:00
parent 7d6b09cf11
commit 5203fb8543
13 changed files with 79 additions and 45 deletions

View File

@@ -5,23 +5,25 @@ import (
json_dataModels "github.com/tecamino/tecamino-json_data/models"
)
func (d *DBMHandler) Get(gets []json_dataModels.Get, id, id2 string) {
if gets == nil {
func (d *DBMHandler) Get(req *json_dataModels.Request, id string) {
if req == nil {
return
} else if len(req.Get) == 0 {
return
}
d.RLock()
defer d.RUnlock()
r := json_data.NewResponse()
r.Id = id2
for _, get := range gets {
resp := json_data.NewResponse()
resp.Id = req.Id
for _, get := range req.Get {
var depth uint = 1
if get.Query != nil {
depth = get.Query.Depth
}
for _, dp := range d.DB.QueryDatapoints(depth, get.Path) {
r.AddGet(json_dataModels.Get{
resp.AddGet(json_dataModels.Get{
Uuid: dp.Uuid,
Path: dp.Path,
Type: dp.Type,
@@ -31,7 +33,7 @@ func (d *DBMHandler) Get(gets []json_dataModels.Get, id, id2 string) {
}
}
if err := d.Conns.SendResponse(id, r); err != nil {
if err := d.Conns.SendResponse(id, resp); err != nil {
d.Log.Error("get.Get", err.Error())
}
}