Fix alert last modified timestamps

mysql timestamp columns do not accept timestamps
This commit is contained in:
Tony Murray
2020-06-15 22:24:14 -05:00
parent c90404e9a9
commit 76a7ea1a63

View File

@@ -114,7 +114,7 @@ class AlertRules
if (is_null($current_state)) {
dbInsert(array('state' => AlertState::ACTIVE, 'device_id' => $device_id, 'rule_id' => $rule['id'], 'open' => 1,'alerted' => 0), 'alerts');
} else {
dbUpdate(['state' => AlertState::ACTIVE, 'open' => 1, 'timestamp' => Carbon::now()->timestamp], 'alerts', 'device_id = ? && rule_id = ?', [$device_id, $rule['id']]);
dbUpdate(['state' => AlertState::ACTIVE, 'open' => 1, 'timestamp' => Carbon::now()], 'alerts', 'device_id = ? && rule_id = ?', [$device_id, $rule['id']]);
}
c_echo(PHP_EOL . 'Status: %rALERT');
}
@@ -127,7 +127,7 @@ class AlertRules
if (is_null($current_state)) {
dbInsert(['state' => AlertState::RECOVERED, 'device_id' => $device_id, 'rule_id' => $rule['id'], 'open' => 1, 'alerted' => 0], 'alerts');
} else {
dbUpdate(['state' => AlertState::RECOVERED, 'open' => 1, 'note' => '', 'timestamp' => Carbon::now()->timestamp], 'alerts', 'device_id = ? && rule_id = ?', [$device_id, $rule['id']]);
dbUpdate(['state' => AlertState::RECOVERED, 'open' => 1, 'note' => '', 'timestamp' => Carbon::now()], 'alerts', 'device_id = ? && rule_id = ?', [$device_id, $rule['id']]);
}
c_echo(PHP_EOL . 'Status: %gOK');