From 3fd2afb9d288e8393b2bd0b2190327e705914493 Mon Sep 17 00:00:00 2001 From: Alexandru Busuioc Date: Thu, 12 Jan 2017 16:36:42 +0200 Subject: [PATCH 1/3] FIx: Serialize 'descending' parameter to boolean instead of object. http://druid.io/docs/latest/querying/timeseriesquery.html --- src/Druid/Query/Aggregation/Timeseries.php | 25 ++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Druid/Query/Aggregation/Timeseries.php b/src/Druid/Query/Aggregation/Timeseries.php index c09567b..a2acbf4 100644 --- a/src/Druid/Query/Aggregation/Timeseries.php +++ b/src/Druid/Query/Aggregation/Timeseries.php @@ -29,7 +29,11 @@ namespace Druid\Query\Aggregation; +use Druid\Query\Component\Descending\Descending; use Druid\Query\Component\DescendingInterface; +use JMS\Serializer\Annotation\Type; +use JMS\Serializer\Annotation\PreSerialize; +use JMS\Serializer\Annotation\PostSerialize; /** * Class Timeseries. @@ -48,11 +52,28 @@ public function __construct() /** * Whether to make descending ordered result. Default is false(ascending). - * @return bool + * @return DescendingInterface */ public function getDescending() { - return $this->descending->getDescending(); + return $this->descending; + } + + /** + * @PreSerialize + */ + public function preSerialize() + { + $this->descending = $this->descending->getDescending(); + } + + /** + * @PostSerialize + */ + public function postSerialize() + { + /** @noinspection PhpParamsInspection */ + $this->setDescending(new Descending($this->descending)); } /** From 81c64845ea99d09295fafe73f44f951e7a844199 Mon Sep 17 00:00:00 2001 From: Alexandru Busuioc Date: Wed, 18 Jan 2017 12:20:58 +0200 Subject: [PATCH 2/3] PSR-2 fix --- src/Druid/Query/Aggregation/GroupBy.php | 1 - src/Druid/Query/QueryInterface.php | 1 - src/Druid/QueryBuilder/TopNQueryBuilder.php | 5 ++++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Druid/Query/Aggregation/GroupBy.php b/src/Druid/Query/Aggregation/GroupBy.php index e40c69d..f977081 100644 --- a/src/Druid/Query/Aggregation/GroupBy.php +++ b/src/Druid/Query/Aggregation/GroupBy.php @@ -29,7 +29,6 @@ namespace Druid\Query\Aggregation; - use Druid\Query\Component\DimensionSpecInterface; use Druid\Query\Component\HavingInterface; use Druid\Query\Component\LimitSpecInterface; diff --git a/src/Druid/Query/QueryInterface.php b/src/Druid/Query/QueryInterface.php index ffb6d85..58cbba2 100644 --- a/src/Druid/Query/QueryInterface.php +++ b/src/Druid/Query/QueryInterface.php @@ -29,7 +29,6 @@ namespace Druid\Query; - use Druid\Query\Exception\RequiredArgumentException; /** diff --git a/src/Druid/QueryBuilder/TopNQueryBuilder.php b/src/Druid/QueryBuilder/TopNQueryBuilder.php index 4ca4bc0..529ec93 100644 --- a/src/Druid/QueryBuilder/TopNQueryBuilder.php +++ b/src/Druid/QueryBuilder/TopNQueryBuilder.php @@ -80,7 +80,10 @@ public function setMetric(MetricInterface $metric) */ public function setThreshold($threshold) { - return $this->addComponent('threshold', $threshold instanceof ThresholdInterface ? $threshold : new Threshold((int)$threshold)); + return $this->addComponent( + 'threshold', + $threshold instanceof ThresholdInterface ? $threshold : new Threshold((int)$threshold) + ); } /** From f27210a2495f344096d003fe9e21988c7e9ea063 Mon Sep 17 00:00:00 2001 From: Alexandru Busuioc Date: Wed, 25 Jan 2017 11:28:16 +0200 Subject: [PATCH 3/3] bugfix --- src/Druid/Query/Aggregation/Timeseries.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Druid/Query/Aggregation/Timeseries.php b/src/Druid/Query/Aggregation/Timeseries.php index 0401ba7..7c79455 100644 --- a/src/Druid/Query/Aggregation/Timeseries.php +++ b/src/Druid/Query/Aggregation/Timeseries.php @@ -65,7 +65,7 @@ public function getDescending() */ public function preSerialize() { - $this->descending = $this->descending->getDescending(); + $this->descending = $this->descending ? $this->descending->getDescending() : null; } /** @@ -74,7 +74,7 @@ public function preSerialize() public function postSerialize() { /** @noinspection PhpParamsInspection */ - $this->setDescending(new Descending($this->descending)); + !is_null($this->descending) && $this->setDescending(new Descending($this->descending)); } /**