[influxdb] Fixes InfluxDB 2.0 issues #9247 and #8960 (#9258)

Signed-off-by: Joan Pujol <joanpujol@gmail.com>
This commit is contained in:
Joan Pujol 2020-12-12 20:32:24 +01:00 committed by GitHub
parent 442a7cd31e
commit 3a5240d00e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 11 deletions

View File

@ -38,18 +38,16 @@ public class Influx2FilterCriteriaQueryCreatorImpl implements FilterCriteriaQuer
public String createQuery(FilterCriteria criteria, String retentionPolicy) {
Flux flux = Flux.from(retentionPolicy);
if (criteria.getBeginDate() != null || criteria.getEndDate() != null) {
RangeFlux range = flux.range();
if (criteria.getBeginDate() != null) {
range = range.withStart(criteria.getBeginDate().toInstant());
}
if (criteria.getEndDate() != null) {
range = range.withStop(criteria.getEndDate().toInstant());
}
flux = range;
RangeFlux range = flux.range();
if (criteria.getBeginDate() != null) {
range = range.withStart(criteria.getBeginDate().toInstant());
} else {
flux = flux.range(-100L, ChronoUnit.YEARS); // Flux needs a mandatory range
range = flux.range(-100L, ChronoUnit.YEARS); // Flux needs a mandatory start range
}
if (criteria.getEndDate() != null) {
range = range.withStop(criteria.getEndDate().toInstant());
}
flux = range;
if (criteria.getItemName() != null) {
flux = flux.filter(measurement().equal(criteria.getItemName()));

View File

@ -69,7 +69,7 @@
<label>Retention Policy / Bucket</label>
<description>The name of the retention policy (Influx DB 1.0) or bucket (InfluxDB 2.0) to write data
</description>
<default>openhab</default>
<default>autogen</default>
</parameter>
<parameter name="replaceUnderscore" type="boolean" required="true" groupName="misc">