Added ability to set a custom SQL query for alert rules. (#9094)

* Added support for AVG in rules

* More updates

* Final work to have advanced sql queries

* Added missing use

* Fix exception when invalid json is passed

* Fixed api for alert rules

* updated docs
This commit is contained in:
Neil Lathwood
2018-09-19 13:47:45 +01:00
committed by Tony Murray
parent 53a1730fc7
commit 466b5a35a8
10 changed files with 200 additions and 116 deletions

View File

@@ -146,7 +146,7 @@ class QueryBuilderParser implements \JsonSerializable
public static function fromJson($json)
{
if (!is_array($json)) {
$json = json_decode($json, true);
$json = json_decode($json, true) ?: [];
}
return new static($json);
@@ -235,7 +235,7 @@ class QueryBuilderParser implements \JsonSerializable
$wrap = false;
if ($expand) {
$sql = 'SELECT * FROM ' . implode(',', $this->getTables());
$sql = 'SELECT * FROM ' .implode(',', $this->getTables());
$sql .= ' WHERE ' . $this->generateGlue() . ' AND ';
// only wrap in ( ) if the condition is OR and there is more than one rule