add new argument for allow origins and query without path and only uuid

This commit is contained in:
Adrian Zürcher
2025-05-28 22:05:47 +02:00
parent c57c22f93a
commit 9605b50198
7 changed files with 93 additions and 76 deletions

View File

@@ -331,8 +331,7 @@ func (d *Datapoint) QueryDatapoints(depth uint, path string) (dps Datapoints) {
var dfs func(current *Datapoint, index int)
dfs = func(current *Datapoint, index int) {
if index == len(parts) {
if index == len(parts) || path == "" {
dps = append(dps, current.GetAllDatapoints(depth)...)
return
}

View File

@@ -25,10 +25,9 @@ var SystemDatapoints uuid.UUID
func NewDBM(conns *serverModels.Connections, log *logging.Logger) *DBM {
return &DBM{
Datapoints: Datapoint{},
Uuids: make(Uuids),
Conns: conns,
Log: log,
Uuids: make(Uuids),
Conns: conns,
Log: log,
}
}
@@ -108,8 +107,10 @@ func (d *DBM) QueryDatapoints(depth uint, uid uuid.UUID, key ...string) []*Datap
return nil
}
dp := d.Uuids[uid]
dps := []*Datapoint{dp}
return append(dps, dp.QueryDatapoints(depth, key[0])...)
if depth == 1 {
return []*Datapoint{dp}
}
return append([]*Datapoint{}, dp.QueryDatapoints(depth, key[0])...)
}
return d.Datapoints.QueryDatapoints(depth, key[0])
}