Return ts in selected time zone offset.

This commit is contained in:
Magnus Åhall 2024-06-27 16:21:16 +02:00
parent 530204c1a5
commit 16b4bd53f4

View File

@ -340,15 +340,28 @@ func DatapointDelete(id int) (err error) { // {{{
return
} // }}}
func DatapointValues(id int, from, to time.Time) (values []DatapointValue, err error) { // {{{
_, err = service.Db.Conn.Exec(`SELECT set_config('timezone', $1, false)`, smonConfig.Timezone().String())
if err != nil {
err = werr.Wrap(err).WithData(smonConfig.Timezone().String())
return
}
rows, err := service.Db.Conn.Queryx(
`
SELECT *
SELECT
id,
datapoint_id,
ts,
value_int,
value_string,
value_datetime
FROM datapoint_value
WHERE
datapoint_id=$1 AND
ts >= $2 AND
ts <= $3
ORDER BY ts DESC
ORDER BY
ts DESC
`,
id,
from,