Added datavalue filtering on date

This commit is contained in:
Magnus Åhall 2024-06-27 08:59:34 +02:00
parent b6e1139e8a
commit 43d8938459
6 changed files with 69 additions and 5 deletions

View file

@ -327,8 +327,21 @@ func DatapointDelete(id int) (err error) { // {{{
}
return
} // }}}
func DatapointValues(id int) (values []DatapointValue, err error) { // {{{
rows, err := service.Db.Conn.Queryx(`SELECT * FROM datapoint_value WHERE datapoint_id=$1 ORDER BY ts DESC LIMIT 500`, id)
func DatapointValues(id int, from, to time.Time) (values []DatapointValue, err error) { // {{{
rows, err := service.Db.Conn.Queryx(
`
SELECT *
FROM datapoint_value
WHERE
datapoint_id=$1 AND
ts >= $2 AND
ts <= $3
ORDER BY ts DESC
`,
id,
from,
to,
)
if err != nil {
err = werr.Wrap(err).WithData(id)
return