public static ReportData GetViewsByPost(DateTime min, DateTime max) { // top 10 DataProvider dp = DataService.Provider; QueryCommand cmd = new QueryCommand(@" select Title, Id, IdCount FROM ( SELECT max(p.Title) as Title, p.Id, " + dp.SqlCountFunction("p.Id") + @" as IdCount from graffiti_Post_Statistics AS ps left outer join graffiti_Posts AS p on p.Id = ps.PostId where ps.DateViewed >= " + dp.SqlVariable("MinDate") + @" and ps.DateViewed < " + dp.SqlVariable("MaxDate") + @" and p.CategoryId in " + RolePermissionManager.GetInClauseForReadPermissions(GraffitiUsers.Current) + @" group by p.Id) as dv order by IdCount desc "); Parameter pDateViewed = PostStatistic.FindParameter("DateViewed"); cmd.Parameters.Add("MinDate", min, pDateViewed.DbType); cmd.Parameters.Add("MaxDate", max.AddDays(1), pDateViewed.DbType); return(GetPostDictionary(cmd, 10)); }
public static IDictionary <DateTime, int> CommentsByDate(DateTime min, DateTime max) { DataProvider dp = DataService.Provider; QueryCommand cmd = new QueryCommand(@" select " + dp.SqlYearFunction("c.Published") + " as dvYear, " + dp.SqlMonthFunction("c.Published") + " as dvMonth, " + dp.SqlDayFunction("c.Published") + " as dvDay, " + dp.SqlCountFunction("c.Id") + @" as IdCount from graffiti_Comments AS c left outer join graffiti_Posts AS p on p.Id = c.PostId where c.Published >= " + dp.SqlVariable("MinDate") + @" and c.Published < " + dp.SqlVariable("MaxDate") + @" and p.CategoryId in " + RolePermissionManager.GetInClauseForReadPermissions(GraffitiUsers.Current) + @" and c.IsDeleted = 0 group by " + dp.SqlYearFunction("c.Published") + ", " + dp.SqlMonthFunction("c.Published") + ", " + dp.SqlDayFunction("c.Published") ); Parameter pPublished = Comment.FindParameter("Published"); cmd.Parameters.Add("MinDate", min, pPublished.DbType); cmd.Parameters.Add("MaxDate", max.AddDays(1), pPublished.DbType); return(GetDateDictionary(cmd)); }
public static ReportData CommentsByPost(DateTime min, DateTime max) { // top 10 DataProvider dp = DataService.Provider; QueryCommand cmd = new QueryCommand(@" SELECT Title, Id, IdCount from ( SELECT max(p.Title) as Title, p.Id, " + dp.SqlCountFunction("c.Id") + @" as IdCount from graffiti_Comments AS c left outer join graffiti_Posts AS p on p.Id = c.PostId where c.Published >= " + dp.SqlVariable("MinDate") + @" and c.Published < " + dp.SqlVariable("MaxDate") + @" and p.CategoryId in " + RolePermissionManager.GetInClauseForReadPermissions(GraffitiUsers.Current) + @" and c.IsDeleted = 0 group by p.Id) as dv order by IdCount desc "); Parameter pPublished = Comment.FindParameter("Published"); cmd.Parameters.Add("MinDate", min, pPublished.DbType); cmd.Parameters.Add("MaxDate", max.AddDays(1), pPublished.DbType); return(GetPostDictionary(cmd, 10)); }
public static ReportData MostPopularPosts() { // top 5 DataProvider dp = DataService.Provider; QueryCommand cmd = new QueryCommand(@" SELECT Title, Id, IdCount FROM ( SELECT p.Title, p.Id, " + dp.SqlCountFunction("p.Id") + @" as IdCount from graffiti_Post_Statistics AS ps left outer join graffiti_Posts AS p on p.Id = ps.PostId where p.CategoryId in " + RolePermissionManager.GetInClauseForReadPermissions(GraffitiUsers.Current) + @" group by p.Title, p.Id) as dv order by IdCount desc "); return(GetPostDictionary(cmd, 5)); }