Fix alarm update in db
This commit is contained in:
parent
f8be28744c
commit
51a52fcb8e
@ -239,16 +239,19 @@ func GetAlarmsRepeated(db *LevelDBStorage) (alarms []*AlarmRepeated, err error)
|
|||||||
|
|
||||||
func PutAlarmRepeated(db *LevelDBStorage, alarm *AlarmRepeated) (err error) {
|
func PutAlarmRepeated(db *LevelDBStorage, alarm *AlarmRepeated) (err error) {
|
||||||
var key string
|
var key string
|
||||||
var id Identifier
|
|
||||||
|
|
||||||
if alarm.Id.IsEmpty() {
|
if alarm.Id.IsEmpty() {
|
||||||
|
var id Identifier
|
||||||
|
|
||||||
key, id, err = db.findBytesKey("alarm-repeated-", IDENTIFIER_LEN)
|
key, id, err = db.findBytesKey("alarm-repeated-", IDENTIFIER_LEN)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
alarm.Id = id
|
||||||
|
} else {
|
||||||
|
key = fmt.Sprintf("alarm-repeated-%s", alarm.Id.ToString())
|
||||||
}
|
}
|
||||||
|
|
||||||
alarm.Id = id
|
|
||||||
// Don't store this, this is autocalculated
|
// Don't store this, this is autocalculated
|
||||||
alarm.Excepts = nil
|
alarm.Excepts = nil
|
||||||
alarm.NextTime = nil
|
alarm.NextTime = nil
|
||||||
@ -293,16 +296,18 @@ func GetAlarmsSingle(db *LevelDBStorage) (alarms []*AlarmSingle, err error) {
|
|||||||
|
|
||||||
func PutAlarmSingle(db *LevelDBStorage, alarm *AlarmSingle) (err error) {
|
func PutAlarmSingle(db *LevelDBStorage, alarm *AlarmSingle) (err error) {
|
||||||
var key string
|
var key string
|
||||||
var id Identifier
|
|
||||||
|
|
||||||
if alarm.Id.IsEmpty() {
|
if alarm.Id.IsEmpty() {
|
||||||
|
var id Identifier
|
||||||
|
|
||||||
key, id, err = db.findBytesKey("alarm-single-", IDENTIFIER_LEN)
|
key, id, err = db.findBytesKey("alarm-single-", IDENTIFIER_LEN)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
alarm.Id = id
|
alarm.Id = id
|
||||||
|
} else {
|
||||||
|
key = fmt.Sprintf("alarm-single-%s", alarm.Id.ToString())
|
||||||
|
}
|
||||||
|
|
||||||
return db.put(key, alarm)
|
return db.put(key, alarm)
|
||||||
}
|
}
|
||||||
@ -363,16 +368,18 @@ func GetAlarmExceptions(db *LevelDBStorage) (alarms []*AlarmException, err error
|
|||||||
|
|
||||||
func PutAlarmException(db *LevelDBStorage, alarm *AlarmException) (err error) {
|
func PutAlarmException(db *LevelDBStorage, alarm *AlarmException) (err error) {
|
||||||
var key string
|
var key string
|
||||||
var id Identifier
|
|
||||||
|
|
||||||
if alarm.Id.IsEmpty() {
|
if alarm.Id.IsEmpty() {
|
||||||
|
var id Identifier
|
||||||
|
|
||||||
key, id, err = db.findBytesKey("alarm-exception-", IDENTIFIER_LEN)
|
key, id, err = db.findBytesKey("alarm-exception-", IDENTIFIER_LEN)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
alarm.Id = id
|
alarm.Id = id
|
||||||
|
} else {
|
||||||
|
key = fmt.Sprintf("alarm-exception-%s", alarm.Id.ToString())
|
||||||
|
}
|
||||||
|
|
||||||
return db.put(key, alarm)
|
return db.put(key, alarm)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user