seanbun-gmail
-
5/6/2009 6:29:24 AM
Incorrect SQL queries behind 2 static methods under HitsInfoProvider class
Hi
1.GetObjectHitsInfo(Int32, Int32, HitsIntervalEnum, String, DateTime, DateTime) 2. GetObjectHitCount(Int32, Int32, HitsIntervalEnum, String, DateTime, DateTime)
I tried to get the pageview and web analytics info with above 2 methods and found they returned incorrect data with given date range. I checked both SQL Queries with SQL Server Profiler and found a bug (potentailly).
In order to get the hitsinfo record within the given date range, the condition of HitsStartTime should be "HitsStartTime >= @TimeBegin" as the red line shown below.
Please correct me if my logic is wrong.
Cheers, Matt
-- Current Query exec sp_executesql N'SELECT SUM(HitsCount) FROM Analytics_Statistics, analytics_dayhits WHERE StatisticsSiteID=@SiteID AND StatisticsCode=@CodeName AND StatisticsID=HitsStatisticsID AND StatisticsObjectID=@ObjectID AND @TimeBegin >= HitsStartTime AND HitsEndTime <= @TimeEnd',N'@SiteID int,@CodeName nvarchar(9),@TimeBegin datetime,@TimeEnd datetime,@ObjectID int',@SiteID=78,@CodeName=N'pageviews',@TimeBegin='2009-05-06 00:00:00',@TimeEnd='2009-05-07 00:00:00',@ObjectID=1234
-- Correct Query exec sp_executesql N'SELECT * FROM Analytics_Statistics, analytics_dayhits WHERE StatisticsSiteID=@SiteID AND StatisticsCode=@CodeName AND StatisticsID=HitsStatisticsID AND StatisticsObjectID=@ObjectID AND @TimeBegin <= HitsStartTime AND @TimeEnd >= HitsEndTime', N'@SiteID int,@CodeName nvarchar(9),@TimeBegin datetime,@TimeEnd datetime,@ObjectID int', @SiteID=78,@CodeName=N'pageviews',@TimeBegin='2009-05-05 00:00:00', @TimeEnd='2009-05-08 00:00:00',@ObjectID=1234
|