Skip to content

Commit

Permalink
fix: take care of dates on HC zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
aelamrani authored and NicolasGeraud committed Jun 8, 2018
1 parent 8a3f3de commit dcf4658
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,22 @@ public DateHistogramResponse executeQuery(Query<DateHistogramResponse> query) th
final String sQuery = this.createQuery(TEMPLATE, dateHistogramQuery);

try {
final long now = System.currentTimeMillis();
final long from = ZonedDateTime
.ofInstant(Instant.ofEpochMilli(now), ZoneId.systemDefault())
.minus(1, ChronoUnit.MONTHS)
.toInstant()
.toEpochMilli();
final long to;
final long from;
if (dateHistogramQuery.timeRange().range().to() != null) {
to = dateHistogramQuery.timeRange().range().to();
from = dateHistogramQuery.timeRange().range().from();
} else {
to = System.currentTimeMillis();
from = ZonedDateTime
.ofInstant(Instant.ofEpochMilli(to), ZoneId.systemDefault())
.minus(1, ChronoUnit.MONTHS)
.toInstant()
.toEpochMilli();
}

final Single<SearchResponse> result = this.client.search(
this.indexNameGenerator.getIndexName(Type.HEALTH_CHECK, from, now),
this.indexNameGenerator.getIndexName(Type.HEALTH_CHECK, from, to),
Type.HEALTH_CHECK.getType(),
sQuery);
return this.toAvailabilityResponseResponse(result.blockingGet(), dateHistogramQuery);
Expand Down

0 comments on commit dcf4658

Please sign in to comment.