Dashboard editing

This commit is contained in:
Magnus Åhall 2026-08-21 11:03:14 +02:00
parent c3fe5951d4
commit dc0ad136e6
6 changed files with 1596 additions and 65 deletions

View file

@ -28,6 +28,7 @@ type Datapoint struct {
Datatype DatapointType
Comment string
LastValue time.Time `db:"last_value"`
DataPointID int `db:"datapoint_id"`
DatapointValueJSON []byte `db:"datapoint_value_json"`
LastDatapointValue DatapointValue
LastDatapointID *int `db:"last_value_id"`
@ -283,7 +284,7 @@ func DatapointRetrieve(id int, name string) (dp Datapoint, err error) { // {{{
}
rows, _ := db.Query(context.Background(), query, param)
dp, err = pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[Datapoint])
dp, err = pgx.CollectExactlyOneRow(rows, pgx.RowToStructByNameLax[Datapoint])
if err != nil {
err = werr.Wrap(err)
return
@ -313,7 +314,7 @@ func DatapointRetrieve(id int, name string) (dp Datapoint, err error) { // {{{
`,
dp.ID,
)
dp, err = pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[Datapoint])
dp.LastDatapointValue, err = pgx.CollectExactlyOneRow(rows, pgx.RowToStructByNameLax[DatapointValue])
if err == sql.ErrNoRows {
err = nil
return