SaaS CMS has officially launched! Learn more now.

Bug in VisitHandler?

Vote:
 

I'm am using visithandler to count visit for two visitable entities, namely Entry and Blog. The following code is used for this...

VisitHandler.AddVisit(new EPiServer.Common.Visits.Visit(_blog, new UserAuthor(CurrentUser)));
VisitHandler.AddVisit(new EPiServer.Common.Visits.Visit(_entry, new UserAuthor(CurrentUser)));

When trying to receive Entry visits i also receive Blog visits and vice versa, this has to be a bug? I can't find anything in the bug list. The following code is used.

VisitableEntityCollection visitedItems = VisitHandler.GetVisitedItems(typeof(Entry), 1,
                1000, TimeSpan.MinValue, out totalItems, new VisitableEntitySortOrder(VisitableEntitySortField.NumVisits, SortingDirection.Descending))

#38943
Apr 26, 2010 10:50
Vote:
 

Hi,

This is a known issue which does not yet have a publicly released fix. You can get a hotfix through EPiServer Support.

We will look into why this is not in the bug list.

 

/Håkan

#38970
Apr 27, 2010 10:18
Vote:
 

You can try this workaround - not very nice but seems to work well:

using System;
using System.Linq;
using EPiServer.Common.Visits;

namespace Utils
{
    public class VisitHandlerFix
    {
        private const int MaxItemCount = 10000;

        public static VisitableEntityCollection GetVisitedItems<T>(int page, int pageSize, TimeSpan explicitCacheExpiration, out int totalItems, params VisitableEntitySortOrder[] sortOrder)
        {
            // bugfix:
            VisitableEntityCollection everything = VisitHandler.GetVisitedItems(typeof(T), 1, MaxItemCount, explicitCacheExpiration, out totalItems, sortOrder);
            VisitableEntityCollection filtered = new VisitableEntityCollection(everything.OfType<T>().ToList());
            totalItems = filtered.Count;

            return new VisitableEntityCollection(filtered.Skip(pageSize * (page - 1)).Take(pageSize).ToList());
        }
    }
}

#42658
Aug 27, 2010 17:54
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.