Adds addRangeFrom() method.
This commit is contained in:
parent
826831b36c
commit
71bca9f1b1
4 changed files with 52 additions and 7 deletions
|
|
@ -4,8 +4,7 @@
|
||||||
|
|
||||||
On this page you will find the methods you can use in the query builder.
|
On this page you will find the methods you can use in the query builder.
|
||||||
|
|
||||||
* [from()](functions/from.md)
|
* [from()](functions/from.md) or [fromBucket()](functions/fromBucket.md)
|
||||||
or [fromBucket()](functions/fromBucket.md)
|
|
||||||
* [fromMeasurement()](functions/fromMeasurement.md)
|
* [fromMeasurement()](functions/fromMeasurement.md)
|
||||||
* [addAggregateWindow()](functions/addAggregateWindow.md)
|
* [addAggregateWindow()](functions/addAggregateWindow.md)
|
||||||
* [addBottom()](functions/addBottom.md)
|
* [addBottom()](functions/addBottom.md)
|
||||||
|
|
@ -20,8 +19,7 @@ or [fromBucket()](functions/fromBucket.md)
|
||||||
* [addMax()](functions/addMax.md)
|
* [addMax()](functions/addMax.md)
|
||||||
* [addMean()](functions/addMean.md)
|
* [addMean()](functions/addMean.md)
|
||||||
* [addMin()](functions/addMin.md)
|
* [addMin()](functions/addMin.md)
|
||||||
* [addRangeStart()](functions/addRangeStart.md)
|
* [addRangeFrom()](functions/addRangeFrom.md) or [addRangeStart()](functions/addRangeStart.md) or [addRangeInBetween()](functions/addRangeInBetween.md)
|
||||||
or [addRangeInBetween()](functions/addRangeInBetween.md)
|
|
||||||
* [addReduce()](functions/addReduce.md)
|
* [addReduce()](functions/addReduce.md)
|
||||||
* [addSort()](functions/addSort.md)
|
* [addSort()](functions/addSort.md)
|
||||||
* [addSum()](functions/addSum.md)
|
* [addSum()](functions/addSum.md)
|
||||||
|
|
|
||||||
41
docs/functions/addRangeFrom.md
Normal file
41
docs/functions/addRangeFrom.md
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
# Flux Query Builder Docs
|
||||||
|
|
||||||
|
## Functions » addRangeFrom()
|
||||||
|
|
||||||
|
### Parameters:
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Required</th>
|
||||||
|
<th>Data type</th>
|
||||||
|
<th>Description</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>from</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>string</td>
|
||||||
|
<td>Relative duration.</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```php
|
||||||
|
->addRangeFrom( '-1h' )
|
||||||
|
```
|
||||||
|
|
||||||
|
This will result in the following Flux function part:
|
||||||
|
|
||||||
|
```
|
||||||
|
|> range(
|
||||||
|
start: -1h
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Extra resources
|
||||||
|
|
||||||
|
* [Flux documentation](https://docs.influxdata.com/flux/v0.x/stdlib/universe/range/)
|
||||||
|
|
@ -57,7 +57,7 @@ trait Basics {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addRange( DateTime $start, ?DateTime $stop = null ): QueryBuilderInterface {
|
public function addRange( mixed $start, ?DateTime $stop = null ): QueryBuilderInterface {
|
||||||
$this->setRequirements();
|
$this->setRequirements();
|
||||||
|
|
||||||
$this->addToQuery(
|
$this->addToQuery(
|
||||||
|
|
@ -73,6 +73,12 @@ trait Basics {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addRangeFrom( string $from ): QueryBuilderInterface {
|
||||||
|
$this->addRange( $from );
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function addRangeInBetween( DateTime $start, DateTime $stop ): QueryBuilderInterface {
|
public function addRangeInBetween( DateTime $start, DateTime $stop ): QueryBuilderInterface {
|
||||||
$this->addRange( $start, $stop );
|
$this->addRange( $start, $stop );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class Range extends Base {
|
||||||
*/
|
*/
|
||||||
private $stop;
|
private $stop;
|
||||||
|
|
||||||
public function __construct( DateTime $start, ?DateTime $stop = null ) {
|
public function __construct( mixed $start, ?DateTime $stop = null ) {
|
||||||
$this->start = new Type( $start );
|
$this->start = new Type( $start );
|
||||||
$this->stop = $stop ? new Type( $stop ) : null;
|
$this->stop = $stop ? new Type( $stop ) : null;
|
||||||
}
|
}
|
||||||
|
|
@ -27,7 +27,7 @@ class Range extends Base {
|
||||||
throw new FunctionRequiredSettingMissingException( 'Range', 'Start setting is required!' );
|
throw new FunctionRequiredSettingMissingException( 'Range', 'Start setting is required!' );
|
||||||
}
|
}
|
||||||
|
|
||||||
$settingsString = 'start: ' . $this->start;
|
$settingsString = str_replace( '"', '', 'start: ' . $this->start );
|
||||||
if ( $this->stop ) {
|
if ( $this->stop ) {
|
||||||
$settingsString .= ', stop: ' . $this->stop;
|
$settingsString .= ', stop: ' . $this->stop;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue