Improve validation
Signed-off-by: David Arendsen <darendsen@gamepoint.com>
This commit is contained in:
parent
3cff68870f
commit
602228a5e8
6 changed files with 53 additions and 44 deletions
|
|
@ -10,6 +10,7 @@ use Arendsen\FluxQueryBuilder\Expression\KeyValue;
|
|||
use Arendsen\FluxQueryBuilder\Expression\KeyFilter;
|
||||
use Arendsen\FluxQueryBuilder\Functions\Filter;
|
||||
use Arendsen\FluxQueryBuilder\Functions\From;
|
||||
use Arendsen\FluxQueryBuilder\Functions\Measurement;
|
||||
use Arendsen\FluxQueryBuilder\Functions\Range;
|
||||
use Arendsen\FluxQueryBuilder\Functions\RawFunction;
|
||||
|
||||
|
|
@ -17,9 +18,7 @@ trait Basics
|
|||
{
|
||||
public function from(array $from): QueryBuilderInterface
|
||||
{
|
||||
$this->addRequiredData(QueryBuilder::REQUIRED_INPUT_FROM, $from);
|
||||
$this->addToQuery(
|
||||
FluxPart::FROM,
|
||||
new From($from)
|
||||
);
|
||||
return $this;
|
||||
|
|
@ -27,14 +26,14 @@ trait Basics
|
|||
|
||||
public function fromBucket(string $bucket): QueryBuilderInterface
|
||||
{
|
||||
$this->from(['bucket' => $bucket]);
|
||||
return $this;
|
||||
return $this->from(['bucket' => $bucket]);
|
||||
}
|
||||
|
||||
public function fromMeasurement(string $measurement): QueryBuilderInterface
|
||||
{
|
||||
$this->addRequiredData(QueryBuilder::REQUIRED_INPUT_MEASUREMENT, $measurement);
|
||||
$this->addKeyFilter(KeyFilter::setEqualTo('_measurement', $measurement));
|
||||
$this->addToQuery(
|
||||
new Measurement($measurement)
|
||||
);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +46,6 @@ trait Basics
|
|||
public function addFilter(KeyValue $keyValue): QueryBuilderInterface
|
||||
{
|
||||
$this->addToQuery(
|
||||
FluxPart::FILTERS,
|
||||
new Filter($keyValue)
|
||||
);
|
||||
return $this;
|
||||
|
|
@ -56,7 +54,6 @@ trait Basics
|
|||
public function addKeyFilter(KeyFilter $keyFilter): QueryBuilderInterface
|
||||
{
|
||||
$this->addToQuery(
|
||||
FluxPart::FILTERS,
|
||||
new Filter($keyFilter)
|
||||
);
|
||||
return $this;
|
||||
|
|
@ -65,7 +62,6 @@ trait Basics
|
|||
public function addFieldFilter(array $fields): QueryBuilderInterface
|
||||
{
|
||||
$this->addToQuery(
|
||||
FluxPart::FILTERS,
|
||||
new Filter($fields)
|
||||
);
|
||||
return $this;
|
||||
|
|
@ -73,9 +69,7 @@ trait Basics
|
|||
|
||||
public function addRange(DateTime $start, ?DateTime $stop = null): QueryBuilderInterface
|
||||
{
|
||||
$this->addRequiredData(QueryBuilder::REQUIRED_INPUT_RANGE, [$start, $stop]);
|
||||
$this->addToQuery(
|
||||
FluxPart::RANGE,
|
||||
new Range($start, $stop)
|
||||
);
|
||||
return $this;
|
||||
|
|
@ -96,7 +90,6 @@ trait Basics
|
|||
public function addRawFunction(string $input): QueryBuilderInterface
|
||||
{
|
||||
$this->addToQuery(
|
||||
FluxPart::RAWFUNCTION,
|
||||
new RawFunction($input)
|
||||
);
|
||||
return $this;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace Arendsen\FluxQueryBuilder\Builder;
|
|||
class FluxPart
|
||||
{
|
||||
public const FROM = 'from';
|
||||
public const MEASUREMENT = 'measurement';
|
||||
public const RANGE = 'range';
|
||||
public const FILTERS = 'filters';
|
||||
public const REDUCE = 'reduce';
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ trait Universe
|
|||
public function addReduce(array $settings, array $identity): QueryBuilderInterface
|
||||
{
|
||||
$this->addToQuery(
|
||||
FluxPart::REDUCE,
|
||||
new Reduce($settings, $identity)
|
||||
);
|
||||
return $this;
|
||||
|
|
@ -28,7 +27,6 @@ trait Universe
|
|||
public function addSort(array $columns, $desc): QueryBuilderInterface
|
||||
{
|
||||
$this->addToQuery(
|
||||
FluxPart::SORT,
|
||||
new Sort($columns, $desc)
|
||||
);
|
||||
return $this;
|
||||
|
|
@ -37,7 +35,6 @@ trait Universe
|
|||
public function addMap($query): QueryBuilderInterface
|
||||
{
|
||||
$this->addToQuery(
|
||||
FluxPart::MAP,
|
||||
new Map($query)
|
||||
);
|
||||
return $this;
|
||||
|
|
@ -46,7 +43,6 @@ trait Universe
|
|||
public function addGroup(array $columns, $mode = 'by'): QueryBuilderInterface
|
||||
{
|
||||
$this->addToQuery(
|
||||
FluxPart::GROUP,
|
||||
new Group($columns, $mode)
|
||||
);
|
||||
return $this;
|
||||
|
|
@ -55,7 +51,6 @@ trait Universe
|
|||
public function addLimit(int $limit, int $offset = 0): QueryBuilderInterface
|
||||
{
|
||||
$this->addToQuery(
|
||||
FluxPart::LIMIT,
|
||||
new Limit($limit, $offset)
|
||||
);
|
||||
return $this;
|
||||
|
|
@ -64,7 +59,6 @@ trait Universe
|
|||
public function addWindow($every, array $options = []): QueryBuilderInterface
|
||||
{
|
||||
$this->addToQuery(
|
||||
FluxPart::WINDOW,
|
||||
new Window($every, $options)
|
||||
);
|
||||
return $this;
|
||||
|
|
@ -73,7 +67,6 @@ trait Universe
|
|||
public function addDuplicate(string $column, string $as): QueryBuilderInterface
|
||||
{
|
||||
$this->addToQuery(
|
||||
FluxPart::DUPLICATE,
|
||||
new Duplicate($column, $as)
|
||||
);
|
||||
return $this;
|
||||
|
|
@ -82,7 +75,6 @@ trait Universe
|
|||
public function addMean(?string $column = ''): QueryBuilderInterface
|
||||
{
|
||||
$this->addToQuery(
|
||||
FluxPart::MEAN,
|
||||
new Mean($column)
|
||||
);
|
||||
return $this;
|
||||
|
|
@ -91,7 +83,6 @@ trait Universe
|
|||
public function addUnWindow(): QueryBuilderInterface
|
||||
{
|
||||
$this->addToQuery(
|
||||
FluxPart::UNWINDOW,
|
||||
new Window('inf')
|
||||
);
|
||||
return $this;
|
||||
|
|
@ -100,7 +91,6 @@ trait Universe
|
|||
public function addAggregateWindow($every, $fn, array $options = []): QueryBuilderInterface
|
||||
{
|
||||
$this->addToQuery(
|
||||
FluxPart::AGGREGATEWINDOW,
|
||||
new AggregateWindow($every, $fn, $options)
|
||||
);
|
||||
return $this;
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue