VisitedCity previousInferredCity = null, nextInferredCity = null;
if (cities.size()==0) {
previousInferredCity = searchCityBeforeDate(guestId, dates.first());
nextInferredCity = searchCityAfterDate(guestId, dates.last());
if (previousInferredCity==null&&nextInferredCity==null) {
WeekMetadata info = new WeekMetadata(year, week);
return info;
}
}
final VisitedCity consensusVisitedCity = getConsensusVisitedCity(cities, previousInferredCity, nextInferredCity);
final List<DayMetadata> dayMetadataForDates = getDayMetadataForDates(guestId, dates);
final TreeMap<String, TimeZone> consensusTimezoneMap = getConsensusTimezoneMap(dayMetadataForDates);
final List<VisitedCity> consensusCities = extractConsensusCities(dayMetadataForDates);
TimezoneMap timezoneMap = TimezoneMap.fromConsensusTimezoneMap(consensusTimezoneMap);
WeekMetadata info = new WeekMetadata(consensusVisitedCity, previousInferredCity, nextInferredCity, consensusTimezoneMap, timezoneMap, cities, consensusCities, year, week);
return info;
}