Source:
private List<UserInteraction> getUserInteractionsData(final Long accountId, final Long startTimestamp, final Long endTimestamp) { final Optional<DeviceAccountPair> deviceAccountPairOptional = deviceDAO.getMostRecentSensePairByAccountId(accountId); if (!deviceAccountPairOptional.isPresent()) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity("This account does not have a sense recently").build()); } if (new DateTime(startTimestamp, DateTimeZone.UTC).plusDays(3).isBefore(new DateTime(endTimestamp, DateTimeZone.UTC))) { throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Maximum time range (3 days) exceeded").build()); } final int slotDurationInMinutes = 5; final Integer missingDataDefaultValue = 0; final AllSensorSampleList sensorSamples = deviceDataDAO.generateTimeSeriesByUTCTimeAllSensors( startTimestamp, endTimestamp, accountId, deviceAccountPairOptional.get().internalDeviceId, slotDurationInMinutes, missingDataDefaultValue ); final List<UserInteraction> userInteractions = new ArrayList<>(); LOGGER.info("{}", sensorSamples.getAvailableSensors()); final List<Sample> waveCountData = sensorSamples.get(Sensor.WAVE_COUNT); final List<Sample> holdCountData = sensorSamples.get(Sensor.HOLD_COUNT); LOGGER.info("wave size {}", waveCountData.size()); LOGGER.info("hold size {}", holdCountData.size()); for (int i=0; i<waveCountData.size(); i++) { userInteractions.add(new UserInteraction( waveCountData.get(i).value, holdCountData.get(i).value, waveCountData.get(i).dateTime, waveCountData.get(i).offsetMillis )); } return userInteractions; }

Target:
private List<UserInteraction> getUserInteractionsData(final Long accountId, final Long startTimestamp, final Long endTimestamp) { final Optional<DeviceAccountPair> deviceAccountPairOptional = deviceDAO.getMostRecentSensePairByAccountId(accountId); if (!deviceAccountPairOptional.isPresent()) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity("This account does not have a sense recently").build()); } final Long timeRangeLimitMillis = 3 * 86400 * 1000L; if ( (endTimestamp - startTimestamp) > timeRangeLimitMillis) { throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Maximum time range (3 days) exceeded").build()); } final int slotDurationInMinutes = 5; final Integer missingDataDefaultValue = 0; final AllSensorSampleList sensorSamples = deviceDataDAO.generateTimeSeriesByUTCTimeAllSensors( startTimestamp, endTimestamp, accountId, deviceAccountPairOptional.get().internalDeviceId, slotDurationInMinutes, missingDataDefaultValue ); final List<UserInteraction> userInteractions = new ArrayList<>(); LOGGER.info("{}", sensorSamples.getAvailableSensors()); final List<Sample> waveCountData = sensorSamples.get(Sensor.WAVE_COUNT); final List<Sample> holdCountData = sensorSamples.get(Sensor.HOLD_COUNT); LOGGER.info("wave size {}", waveCountData.size()); LOGGER.info("hold size {}", holdCountData.size()); for (int i=0; i<waveCountData.size(); i++) { userInteractions.add(new UserInteraction( waveCountData.get(i).value, holdCountData.get(i).value, waveCountData.get(i).dateTime, waveCountData.get(i).offsetMillis )); } return userInteractions; }