wip: more fixes, figure out main problem

This commit is contained in:
saji 2024-02-18 13:40:41 -06:00
parent 8af1b725d1
commit e551390089

View file

@ -23,13 +23,13 @@ func (tdb *TelemDb) GetValues(ctx context.Context, packetName, field string , st
const SqlFrag = ` const SqlFrag = `
SELECT SELECT
datetime(ts /1000.0, 'unixepoch', 'subsec') as timestamp, datetime(ts /1000.0, 'unixepoch', 'subsec') as timestamp,
json_extract(data, ?) as val json_extract(data, '$.' || ?) as val
FROM bus_events WHERE name IS ?; FROM bus_events WHERE name IS ? AND timestamp IS NOT NULL
` `
fmt.Print(start, end, packetName, field)
rows, err := tdb.db.QueryxContext(ctx, "'$.current'", packetName) rows, err := tdb.db.QueryxContext(ctx, SqlFrag, field, packetName, start, end)
if err != nil { if err != nil {
fmt.Print(err)
return nil, err return nil, err
} }
defer rows.Close() defer rows.Close()
@ -38,11 +38,12 @@ func (tdb *TelemDb) GetValues(ctx context.Context, packetName, field string , st
var d Datum var d Datum
err = rows.StructScan(&d) err = rows.StructScan(&d)
if err != nil { if err != nil {
fmt.Print(err)
return data, err return data, err
} }
data = append(data, d) data = append(data, d)
} }
fmt.Print(data)
return data, nil return data, nil
} }