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/Aggregation/Timeseries.php b/src/Druid/Query/Aggregation/Timeseries.php index 4a9ca9e..7c79455 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; use Druid\Query\Exception\RequiredArgumentException; /** @@ -49,11 +53,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 ? $this->descending->getDescending() : null; + } + + /** + * @PostSerialize + */ + public function postSerialize() + { + /** @noinspection PhpParamsInspection */ + !is_null($this->descending) && $this->setDescending(new Descending($this->descending)); } /** 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) + ); } /**