November Happy Hour will be moved to Thursday December 5th.

How to Get most viewed pages in a date range?

Vote:
 

I'm trying throught the community's visithandler get top 5 viewed cms pages in a certain time period. 

For example, The most viewed at http://world.episerver.com/Articles/ 

But the problem with worlds articles is that they are based on the beginning of publish. We find it more interesting in visit in the latest month. 

I'm tring to use the Visitquery, and setup quite simple:

var visitQuery = new VisitQuery();

visitQuery.VisitedDate = new DateTimeCriterion();
visitQuery.VisitedDate.Operator = ComparisonOperator.GreaterThan | ComparisonOperator.Equals;
visitQuery.VisitedDate.Value = DateTime.Now.AddDays(-5);

visitQuery.VisitedDate.Operator2 = ComparisonOperator.LessThan | ComparisonOperator.Equals;
visitQuery.VisitedDate.Value2 = DateTime.Now; 

var result = QueryHandler.Instance.GetQueryResult<PageDataCommunityEntity, EntityCollection>(visitQuery);


However, this results in mypage thingy exception:

could not resolve property: VisitedDate of: EPiServer.Community.MyPage.Visit [SELECT EPiServerCommunityMyPageVisit FROM EPiServer.Community.MyPage.Visit AS EPiServerCommunityMyPageVisit    WHERE ((EPiServerCommunityMyPageVisit.VisitedDate >= :p0 AND EPiServerCommunityMyPageVisit.VisitedDate <= :p1))    ]

I easilly get most viewed as world does by

var mostVisitedNews = VisitHandler.Instance.GetVisitedItems(typeof(PageDataCommunityEntity),
                   EntityStatus.Approved, 1, 100, TimeSpan.MinValue, out totalItems,
                   new VisitableEntitySortOrder(VisitableEntitySortField.NumVisits, SortingDirection.Descending));

But again, that is not the solution I'm after.

#112210
Oct 24, 2014 14:12
Vote:
 
<p>The generic arguments used with GetQueryResult look incorrect (you'll get MyPage.Visit objects from MyPage.VisitQuery).</p> <p></p> <p>While it does appear that&nbsp;MyPage.VisitQuery may not be what you needed&nbsp;(it looks like you are dealing with the generic visits, not the older mypage-specific visits) it does seem like there may be a bug in the Mypage.Visit query handling&nbsp;because other than the generic arguments the query looks valid.&nbsp;</p> <p></p> <p>Assuming the problem remains after correcting the generic arguments I would ask you to <a href="../../../Support/Register-Support-Incident/">contact Support</a>&nbsp;to further investigate that problem.</p>
#112373
Oct 28, 2014 10:41
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.