/** * @param itemList * @param period * @param request * @return * @throws EnMeSearchException */ private List<HashTagDetailStats> compareList( final List<ItemStatDetail> itemList, final SearchPeriods period, final HttpServletRequest request) throws EnMeSearchException { Integer month = 0; Integer monthB; String rangeSubLabel = null; boolean existItemStatDetailLabel = false; List<HashTagDetailStats> tagDetailStatsCompare = new ArrayList<HashTagDetailStats>(); // FIXME: It's limited only for dates in the same year, upgrade to accept dates for different // year. for (int i = 0; i < itemList.size(); i++) { Long countItems = 0L; monthB = this.getLabelDateValue(period, itemList.get(i).getDate()); for (int j = 0; j < itemList.size(); j++) { month = this.getLabelDateValue(period, itemList.get(j).getDate()); if (monthB == month) { countItems++; } } // check if the label exist previously existItemStatDetailLabel = checkLabelExistsHashTagDetailStat(tagDetailStatsCompare, monthB.toString()); if (!existItemStatDetailLabel) { rangeSubLabel = this.getHashTagStatsDataRangeLabel(period.toString(), monthB, request); tagDetailStatsCompare.add( this.createTagDetailsStats(monthB.toString(), countItems, rangeSubLabel)); } } return tagDetailStatsCompare; }
/** * Return total votes by tweetpoll filtered by hashtag. * * @param tagName * @param period * @return */ private Long retrieveTweetPollTotalVotesByHashTag( final String tagName, final SearchPeriods period) { Long totalTweetPollVotes = 0L; // 1- Retrieve a tweetpoll list filtered by hashtag and specific period final List<TweetPoll> tweetPolls = this.getTweetPollsByHashTag(tagName, null, null, TypeSearchResult.HASHTAG, period); log.debug( "TweetPolls by HashTag ****************************************** " + tweetPolls.size() + "Period ***********************" + period.toString()); // 2- Iterate tweetpoll list and sum of votes for each tweetpoll for (TweetPoll tweetPoll : tweetPolls) { final Long votesByTweetPoll = getTweetPollDao().getTotalVotesByTweetPollId(tweetPoll.getTweetPollId()); totalTweetPollVotes = totalTweetPollVotes + votesByTweetPoll.intValue(); } log.debug( "Total Votes by Tweetpoll ******************************************" + totalTweetPollVotes); return totalTweetPollVotes; }