#3, added datapoint comment
This commit is contained in:
parent
f29693a066
commit
42b1a20531
9 changed files with 173 additions and 3 deletions
13
datapoint.go
13
datapoint.go
|
|
@ -25,6 +25,7 @@ type Datapoint struct {
|
|||
Group string
|
||||
Name string
|
||||
Datatype DatapointType
|
||||
Comment string
|
||||
LastValue time.Time `db:"last_value"`
|
||||
DatapointValueJSON []byte `db:"datapoint_value_json"`
|
||||
LastDatapointValue DatapointValue
|
||||
|
|
@ -73,11 +74,12 @@ func (dp Datapoint) Update() (err error) { // {{{
|
|||
|
||||
if dp.ID == 0 {
|
||||
_, err = service.Db.Conn.Exec(
|
||||
`INSERT INTO datapoint("group", name, datatype, nodata_problem_seconds) VALUES($1, $2, $3, $4)`,
|
||||
`INSERT INTO datapoint("group", name, datatype, nodata_problem_seconds, comment) VALUES($1, $2, $3, $4, $5)`,
|
||||
dp.Group,
|
||||
name,
|
||||
dp.Datatype,
|
||||
dp.NodataProblemSeconds,
|
||||
dp.Comment,
|
||||
)
|
||||
} else {
|
||||
/* Keep nodata_is_problem as is unless the nodata_problem_seconds is changed.
|
||||
|
|
@ -90,10 +92,11 @@ func (dp Datapoint) Update() (err error) { // {{{
|
|||
"group"=$2,
|
||||
name=$3,
|
||||
datatype=$4,
|
||||
nodata_problem_seconds=$5,
|
||||
comment=$5,
|
||||
nodata_problem_seconds=$6,
|
||||
nodata_is_problem = (
|
||||
CASE
|
||||
WHEN $5 != nodata_problem_seconds THEN false
|
||||
WHEN $6 != nodata_problem_seconds THEN false
|
||||
ELSE
|
||||
nodata_is_problem
|
||||
END
|
||||
|
|
@ -105,6 +108,7 @@ func (dp Datapoint) Update() (err error) { // {{{
|
|||
dp.Group,
|
||||
name,
|
||||
dp.Datatype,
|
||||
dp.Comment,
|
||||
dp.NodataProblemSeconds,
|
||||
)
|
||||
}
|
||||
|
|
@ -161,6 +165,7 @@ func DatapointsRetrieve() (dps []Datapoint, err error) { // {{{
|
|||
dp.datatype,
|
||||
dp.last_value,
|
||||
dp.group,
|
||||
dp.comment,
|
||||
dp.nodata_problem_seconds,
|
||||
|
||||
dpv.id AS v_id,
|
||||
|
|
@ -190,6 +195,7 @@ func DatapointsRetrieve() (dps []Datapoint, err error) { // {{{
|
|||
Group string
|
||||
Name string
|
||||
Datatype DatapointType
|
||||
Comment string
|
||||
LastValue time.Time `db:"last_value"`
|
||||
NodataProblemSeconds int `db:"nodata_problem_seconds"`
|
||||
|
||||
|
|
@ -214,6 +220,7 @@ func DatapointsRetrieve() (dps []Datapoint, err error) { // {{{
|
|||
dp.Name = res.Name
|
||||
dp.Group = res.Group
|
||||
dp.Datatype = res.Datatype
|
||||
dp.Comment = res.Comment
|
||||
dp.LastValue = res.LastValue
|
||||
dp.Found = true
|
||||
dp.NodataProblemSeconds = res.NodataProblemSeconds
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue