@Test public void testGetPeriodsWeekly() { for (int i = 0; i < repetitions; i++) { final Instant a = randomInstant(); final Instant b = randomInstant(); final Instant from = Ordering.natural().min(a, b); final Instant to = Ordering.natural().max(a, b); logger.info("from {} to {} {}", from, to, DataResolution.WEEKLY.name()); final List<Tuple<Instant, Instant>> periods = InfluxStatisticsProvider.getPeriods(from, to, DataResolution.WEEKLY, ZoneId.of("Z")); assertEquals(1, periods.size()); assertEquals(from, periods.get(0).getA()); assertEquals(to, periods.get(0).getB()); } }
protected static List<Tuple<Instant, Instant>> getPeriods(final Instant from, final Instant to, DataResolution resolution, ZoneId zoneId) { switch (resolution) { case MONTHLY: return getMonthPeriods(getMonths(from, to, zoneId), from, to); case YEARLY: return getYearPeriods(getYears(from, to, zoneId), from, to); case DAILY: case WEEKLY: default: return Collections.singletonList(new Tuple<>(from, to)); } }
InfluxStatisticsProvider implements StatisticsProvider { protected static List<Tuple<Instant, Instant>> getPeriods(final Instant from, final Instant to, DataResolution resolution, ZoneId zoneId) { switch (resolution) { case MONTHLY: return getMonthPeriods(getMonths(from, to, zoneId), from, to); case YEARLY: return getYearPeriods(getYears(from, to, zoneId), from, to); case DAILY: case WEEKLY: default: return Collections.singletonList(new Tuple<>(from, to)); } } }
InfluxStatisticsProvider implements StatisticsProvider { protected static List<Tuple<Instant, Instant>> getPeriods(final Instant from, final Instant to, DataResolution resolution, ZoneId zoneId) { switch (resolution) { case MONTHLY: return getMonthPeriods(getMonths(from, to, zoneId), from, to); case YEARLY: return getYearPeriods(getYears(from, to, zoneId), from, to); case DAILY: case WEEKLY: default: return Collections.singletonList(new Tuple<>(from, to)); } } InfluxStatisticsProvider(
      StatisticsProviderInfluxService service,
      String id,
      ResourceType resourceType,
      String title,
      String description
  ); }
InfluxStatisticsProvider implements StatisticsProvider { protected static List<Tuple<Instant, Instant>> getPeriods(final Instant from, final Instant to, DataResolution resolution, ZoneId zoneId) { switch (resolution) { case MONTHLY: return getMonthPeriods(getMonths(from, to, zoneId), from, to); case YEARLY: return getYearPeriods(getYears(from, to, zoneId), from, to); case DAILY: case WEEKLY: default: return Collections.singletonList(new Tuple<>(from, to)); } } InfluxStatisticsProvider(
      StatisticsProviderInfluxService service,
      String id,
      ResourceType resourceType,
      String title,
      String description
  ); @Override String getId(); @Override ResourceType getResourceType(); @Override String getTitle(); @Override String getDescription(); @Override int hashCode(); @Override boolean equals(Object o); }
InfluxStatisticsProvider implements StatisticsProvider { protected static List<Tuple<Instant, Instant>> getPeriods(final Instant from, final Instant to, DataResolution resolution, ZoneId zoneId) { switch (resolution) { case MONTHLY: return getMonthPeriods(getMonths(from, to, zoneId), from, to); case YEARLY: return getYearPeriods(getYears(from, to, zoneId), from, to); case DAILY: case WEEKLY: default: return Collections.singletonList(new Tuple<>(from, to)); } } InfluxStatisticsProvider(
      StatisticsProviderInfluxService service,
      String id,
      ResourceType resourceType,
      String title,
      String description
  ); @Override String getId(); @Override ResourceType getResourceType(); @Override String getTitle(); @Override String getDescription(); @Override int hashCode(); @Override boolean equals(Object o);  }