public List <DownloadInfo> GetTopDownloads(DateTime startDate, DateTime endDate) { string sql = "SELECT sum(Downloads), RP.Platform, RE.* " + "FROM ReleasePackage RP, `Release` RE, Project P " + "WHERE RP.Date >= {0} AND RP.Date < {1} AND RP.ReleaseId = RE.Id AND RE.ProjectId = P.Id AND P.ApplicationId = {2} " + "GROUP BY RP.Platform, RP.ReleaseId " + "ORDER BY sum(Downloads) DESC"; List <DownloadInfo> stats = new List <DownloadInfo> (); using (DbDataReader r = db.ExecuteSelect(sql, startDate, endDate, userModel.CurrentApplication.Id)) { while (r.Read()) { DownloadInfo di = new DownloadInfo(); di.Count = r.IsDBNull(0) ? 0 : r.GetInt32(0); di.Platform = r.GetString(1); di.Release = db.ReadObject <Release> (r); stats.Add(di); } } return(stats); }
public List<DownloadInfo> GetTopDownloads(DateTime startDate, DateTime endDate) { string sql = "SELECT sum(Downloads), RP.Platform, RE.* " + "FROM ReleasePackage RP, `Release` RE, Project P " + "WHERE RP.Date >= {0} AND RP.Date < {1} AND RP.ReleaseId = RE.Id AND RE.ProjectId = P.Id AND P.ApplicationId = {2} " + "GROUP BY RP.Platform, RP.ReleaseId " + "ORDER BY sum(Downloads) DESC"; List<DownloadInfo> stats = new List<DownloadInfo> (); using (DbDataReader r = db.ExecuteSelect (sql, startDate, endDate, userModel.CurrentApplication.Id)) { while (r.Read ()) { DownloadInfo di = new DownloadInfo (); di.Count = r.IsDBNull (0) ? 0 : r.GetInt32 (0); di.Platform = r.GetString (1); di.Release = db.ReadObject<Release> (r); stats.Add (di); } } return stats; }