Added datavalue filtering on date
This commit is contained in:
parent
b6e1139e8a
commit
43d8938459
6 changed files with 69 additions and 5 deletions
17
datapoint.go
17
datapoint.go
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue