public int GetAllCount(AnalyticsQueryModel query) { var queryable = GetQueryable(); queryable = ApplyFilters(queryable, query); return(queryable.Count()); }
public IList <SingleStatDto> GetByTag(AnalyticsQueryModel query) { if (_tagService == null) { throw (new Exception("Must enable Orchard.Tags")); } var tags = _tagService.GetTags().Select(x => new SingleStatDto { Name = x.TagName }).ToList(); foreach (var tag in tags) { var queryable = GetQueryable(); queryable = ApplyFilters(queryable, query); tag.Count = queryable.Where(x => x.Tags.Contains(tag.Name)).Count(); } var result = tags.OrderByDescending(x => x.Count) .Skip(query.Skip); if (query.Take > 0) { result = result.Take(query.Take); } return(result.ToList()); }
public IList <RawAnalyticsDto> GetAll(AnalyticsQueryModel query) { var queryable = GetQueryable(); queryable = ApplyFilters(queryable, query); queryable = queryable.OrderByDescending(x => x.VisitDateUtc) .Skip(query.Skip); if (query.Take > 0) { queryable = queryable.Take(query.Take); } var items = queryable .Select(x => new RawAnalyticsDto { Tags = x.Tags, UserIdentifier = !string.IsNullOrWhiteSpace(x.UserIdentifier) ? x.UserIdentifier : T("Anonymous").ToString(), Url = x.Url, VisitDate = x.VisitDateUtc.ToLocalTime() }).ToList(); foreach (var item in items) { var tags = (item.Tags ?? "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); Array.Sort(tags); item.Tags = string.Join(", ", tags); } return(items); }
private int GetGroupByCount(AnalyticsQueryModel query, Expression <Func <AnalyticsEntry, string> > groupSelector) { var queryable = GetQueryable(); queryable = ApplyFilters(queryable, query); return(queryable.Select(groupSelector).Distinct().Count()); }
public int GetByTagCount(AnalyticsQueryModel query) { if (_tagService == null) { throw (new Exception("Must enable Orchard.Tags")); } return(_tagService.GetTags().Count()); }
private IList <SingleStatDto> GetGroupByItems(AnalyticsQueryModel query, Expression <Func <AnalyticsEntry, string> > groupSelector) { var queryable = GetGroupBy(query, groupSelector) .Skip(query.Skip); if (query.Take > 0) { queryable = queryable.Take(query.Take); } return(queryable.ToList()); }
private IQueryable <SingleStatDto> GetGroupBy(AnalyticsQueryModel query, Expression <Func <AnalyticsEntry, string> > groupSelector) { var queryable = GetQueryable(); queryable = ApplyFilters(queryable, query); return(queryable.GroupBy(groupSelector) .OrderByDescending(x => x.Count()) .Select(x => new SingleStatDto { Name = x.Key, Count = x.Count() })); }
public int GetByPageCount(AnalyticsQueryModel query) { return(GetGroupByCount(query, x => x.Url)); }
/// <summary> /// Returns a list of unqiue page URLs with the number of times they have been /// visited by a user. /// </summary> /// <param name="skip">Index of row to return from.</param> /// <param name="take">Number of rows to take.</param> /// <returns>List of page URLs with their view count.</returns> public IList <SingleStatDto> GetByPage(AnalyticsQueryModel query) { return(GetGroupByItems(query, x => x.Url)); }
private IQueryable <AnalyticsEntry> ApplyFilters(IQueryable <AnalyticsEntry> queryable, AnalyticsQueryModel query) { queryable = ApplyDateFilter(queryable, query.FromUtc, query.ToUtc); queryable = ApplyTermFilter(queryable, query.Term); return(queryable); }
public int GetByUserCount(AnalyticsQueryModel query) { return(GetGroupByCount(query, x => x.UserIdentifier)); }
/// <summary> /// Returns a list of unqiue UserIdentifiers with the number of times they have been /// viewed a page. /// </summary> /// <param name="from">Index of row to return from.</param> /// <param name="to">Index of row to return up to.</param> /// <returns>List of UserIdentifiers with their view count.</returns> public IList <SingleStatDto> GetByUser(AnalyticsQueryModel query) { return(GetGroupByItems(query, x => x.UserIdentifier)); }