Exemple #1
0
        private UserHistoryInfo AggregateInfo(List <PageViewInfo> userHistory)
        {
            var filtered = userHistory.Where(info => DateTime.Compare(info.TimeStamp.Date, DateTime.Today.AddDays(-7)) > 0).ToList();

            var pageCount = filtered.GroupBy(info => info.PageName).ToDictionary(gp => gp.Key, gp => gp.ToList().Count);
            var maxViews  = pageCount.Values.Max();

            var daysActive = filtered.Select(info => info.TimeStamp.Date).Distinct();

            return(new UserHistoryInfo
            {
                number_pages_viewed_the_last_7_days = pageCount.Keys.Count,
                time_spent_on_site_last_7_days = IntervalHelper.GetMinutesSpentOnSite(filtered.Select(i => i.TimeStamp).ToList()),
                number_of_days_active_last_7_days = daysActive.Count(),
                most_viewed_page_last_7_days = pageCount.First(kv => kv.Value == maxViews).Key
            });
        }
Exemple #2
0
        private UserHistoryInfo AggregateInfo(List <Row> rows)
        {
            var filtered = rows.Where(row => DateTime.Compare(row.GetValue <DateTime>("time_stamp"), DateTime.Today.AddDays(-7)) > 0).ToList();

            var pageCount = filtered.GroupBy(row => row.GetValue <string>("page_name")).ToDictionary(gp => gp.Key, gp => gp.ToList().Count);
            var maxViews  = pageCount.Values.Max();

            var daysActive = filtered.Select(row => row.GetValue <DateTime>("time_stamp").Date).Distinct();

            return(new UserHistoryInfo
            {
                number_pages_viewed_the_last_7_days = pageCount.Keys.Count,
                time_spent_on_site_last_7_days = IntervalHelper.GetMinutesSpentOnSite(filtered.Select(row => row.GetValue <DateTime>("time_stamp")).ToList()),
                number_of_days_active_last_7_days = daysActive.Count(),
                most_viewed_page_last_7_days = pageCount.First(kv => kv.Value == maxViews).Key
            });
        }