Source:
<code>public Optional<InsightCard.Category> generateFutureInsightsByCategory(final Long accountId, final InsightCard.Category category, final DateTime publicationDateLocal) { <START> final Optional<Integer> timeZoneOffsetOptional = sleepStatsDAODynamoDB.getTimeZoneOffset(accountId); <END> if (!timeZoneOffsetOptional.isPresent()) { LOGGER.debug("action=insight-absent insight=correlation_temperature reason=timezoneoffset-absent account_id={}", accountId); return Optional.absent(); } final Integer timeZoneOffset = timeZoneOffsetOptional.get(); final DateTime publicationDateUTC = publicationDateLocal.minusMillis(timeZoneOffset); Optional<InsightCard> insightCardOptional = Optional.absent(); switch (category) { case PARTNER_MOTION: insightCardOptional = PartnerMotionInsight.getInsights(accountId, deviceReadDAO, sleepStatsDAODynamoDB, publicationDateUTC); break; case CORRELATION_TEMP: insightCardOptional = CorrelationTemperature.getInsights(accountId, publicationDateUTC); break; } if (insightCardOptional.isPresent()) { if (marketingInsightPool.contains(category)) { marketingInsightsSeenDAODynamoDB.updateSeenCategories(accountId, category); } LOGGER.info("action=generated_insight_card category={} account_id={} next_action=insert_into_dynamo", insightCardOptional.get(), accountId); this.insightsDAODynamoDB.insertInsight(insightCardOptional.get()); final InsightsLastSeen newInsight = new InsightsLastSeen(accountId, insightCardOptional.get().category, publicationDateUTC); this.insightsLastSeenDAO.markLastSeen(newInsight); return Optional.of(category); } return Optional.absent(); }</code><technical_language>gah, approved PR put getTimeZoneOffset in sleep stats [shudders]</technical_language>

Target:
public Optional<InsightCard.Category> generateFutureInsightsByCategory(final Long accountId, final InsightCard.Category category, final DateTime publicationDateLocal) { final Optional<Integer> timeZoneOffsetOptional = sleepStatsDAODynamoDB.getTimeZoneOffset(accountId); if (!timeZoneOffsetOptional.isPresent()) { LOGGER.info("action=insight-absent insight=correlation_temperature reason=timezoneoffset-absent account_id={}", accountId); return Optional.absent(); } final Integer timeZoneOffset = timeZoneOffsetOptional.get(); final DateTime publicationDateUTC = publicationDateLocal.minusMillis(timeZoneOffset); Optional<InsightCard> insightCardOptional = Optional.absent(); switch (category) { case PARTNER_MOTION: insightCardOptional = PartnerMotionInsight.getInsights(accountId, deviceReadDAO, sleepStatsDAODynamoDB, publicationDateUTC); break; case CORRELATION_TEMP: insightCardOptional = CorrelationTemperature.getInsights(accountId, publicationDateUTC); break; } if (insightCardOptional.isPresent()) { if (marketingInsightPool.contains(category)) { marketingInsightsSeenDAODynamoDB.updateSeenCategories(accountId, category); } LOGGER.info("action=generated_insight_card category={} account_id={} next_action=insert_into_dynamo", insightCardOptional.get(), accountId); this.insightsDAODynamoDB.insertInsight(insightCardOptional.get()); final InsightsLastSeen newInsight = new InsightsLastSeen(accountId, insightCardOptional.get().category, publicationDateUTC); this.insightsLastSeenDAO.markLastSeen(newInsight); return Optional.of(category); } return Optional.absent(); }