public List<StatisticDetailsBean> getViewDetailsStatisticData( Date from, Date to, String pageTitle) { try { List<StatisticDetailsBean> results = new ArrayList<StatisticDetailsBean>(); if (StringUtils.isEmpty(pageTitle)) { return results; } List<List<String>> gaData = null; if (from == null && to == null) { gaData = GoogleAnalyticsManager.getInstance().getAllViewDetailsAnalyticsData(pageTitle); } else { String startDate = DateUtil.convertDateToStringFormat(from, DateUtil.GOOGLE_DATE_FORMAT); String endDate = DateUtil.convertDateToStringFormat(to, DateUtil.GOOGLE_DATE_FORMAT); gaData = GoogleAnalyticsManager.getInstance() .getViewDetailsAnalyticsData(startDate, endDate, pageTitle); } for (List<String> row : gaData) { StatisticDetailsBean viewDetailBean = initStatisticBeanFromGaData(row); results.add(viewDetailBean); } return results; } catch (Exception e) { throw new RuntimeException( "Failed to get view details statistic data [pageTitle = " + pageTitle + "]", e); } }
public List<StatisticDetailsBean> getViewsStatisticData(Date from, Date to) { try { List<List<String>> gaData = null; if (from == null && to == null) { gaData = GoogleAnalyticsManager.getInstance().getAllViewAnalyticsData(); } else { String startDate = DateUtil.convertDateToStringFormat(from, DateUtil.GOOGLE_DATE_FORMAT); String endDate = DateUtil.convertDateToStringFormat(to, DateUtil.GOOGLE_DATE_FORMAT); gaData = GoogleAnalyticsManager.getInstance().getViewAnalyticsData(startDate, endDate); } List<StatisticDetailsBean> results = buildStatisicBeanFromGaData(gaData); return results; } catch (Exception e) { throw new RuntimeException("Failed to get Views statistic data", e); } }
private void buildViewStatisticBean( List<OverviewStatisticBean> statisticBeans, Date toDate, Date fromLast7Days, Date fromLast30Days) throws IOException { int total = GoogleAnalyticsManager.getInstance().getTotalPageViews(); String endDate = DateUtil.convertDateToStringFormat(toDate, DateUtil.GOOGLE_DATE_FORMAT); String startDate = DateUtil.convertDateToStringFormat(fromLast7Days, DateUtil.GOOGLE_DATE_FORMAT); int last7Days = GoogleAnalyticsManager.getInstance().getPageviews(startDate, endDate); startDate = DateUtil.convertDateToStringFormat(fromLast30Days, DateUtil.GOOGLE_DATE_FORMAT); int last30Days = GoogleAnalyticsManager.getInstance().getPageviews(startDate, endDate); OverviewStatisticBean statisticBean = new OverviewStatisticBean( "View", total, last7Days, last30Days, WebConstants.FixValue.VIEW_REPORT); statisticBeans.add(statisticBean); }