From 16b4bd53f4f4d7d96eef863530645c70843e0a82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20=C3=85hall?= Date: Thu, 27 Jun 2024 16:21:16 +0200 Subject: [PATCH] Return ts in selected time zone offset. --- datapoint.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/datapoint.go b/datapoint.go index 3563a5f..a75491a 100644 --- a/datapoint.go +++ b/datapoint.go @@ -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,