//
        // GET: /Stability/

        public ActionResult Index()
        {
            udcEntities db = new udcEntities();
            var         q  =
                from s in db.Sessions
                where s.ClientSessionId != 0     // ignore welcome sessions
                where !s.IsDebug                 // ignore debug builds
                join tag in db.TaggedCommits on s.CommitId equals tag.CommitId
                where tag.IsRelease              // only use released versions, not branch
                group new {
                IsCrashed = s.FirstException != null,
                IsKilled  = s.EndTime == null,
                s.StartTime,
                CrashTime = s.FirstException ?? s.EndTime ?? s.LastFeatureUse
            } by new { s.UserId, Date = EntityFunctions.TruncateTime(s.StartTime), tag.Name };

            Debug.WriteLine(((System.Data.Objects.ObjectQuery)q).ToTraceString());
            var resultList = (
                from g in q.AsEnumerable()                 // don't do this on DB, EF generates too slow SQL
                group g by new { g.Key.Name } into g
                select new {
                TagName = g.Key.Name,
                UserDaysWithCrash = g.Count(g2 => g2.Any(s => s.IsCrashed)),
                UserDaysWithKilled = g.Count(g2 => g2.Any(s => s.IsKilled)),
                UserDays = g.Count(),
                SessionsWithCrashOrKilled = g.Sum(g2 => g2.Count(s => s.IsKilled || s.IsCrashed)),
                TotalSessionLength = g.Sum(g2 => g2.Sum(s => Math.Max(0, ((s.CrashTime - s.StartTime) ?? TimeSpan.Zero).TotalHours)))
            }
                ).OrderBy(g => g.TagName, new VersionNameComparer()).ToList();

            foreach (var item in resultList)
            {
                Debug.WriteLine(item.ToString());
            }

            Chart  chart   = new Chart();
            Series crashes = chart.Series.Add("Exceptions");
            Series killed  = chart.Series.Add("Sessions without clean exit");

            crashes.ChartType = SeriesChartType.Line;
            killed.ChartType  = SeriesChartType.Line;

            Chart  chart2         = new Chart();
            Series crashFrequency = chart2.Series.Add("Crash Frequency");

            crashFrequency.ChartType = SeriesChartType.Line;

            foreach (var row in resultList)
            {
                crashes.Points.AddXY(row.TagName, 100 * (double)row.UserDaysWithCrash / row.UserDays);
                killed.Points.AddXY(row.TagName, 100 * (double)row.UserDaysWithKilled / row.UserDays);
                crashFrequency.Points.AddXY(row.TagName, row.SessionsWithCrashOrKilled / row.TotalSessionLength);
            }
            ViewData.Model             = chart;
            ViewData["CrashFrequency"] = chart2;
            return(View());
        }
Beispiel #2
0
        public ActionResult Index(EnvironmentViewModel model)
        {
            udcEntities db = new udcEntities();

            model.Charts = db.EnvironmentDataNames.Select(n => new EnvironmentViewChart {
                Id = n.EnvironmentDataNameId, Title = n.EnvironmentDataName1
            }).ToList();
            model.Charts.RemoveAll(c => c.Title == "platform" || c.Title == "appVersion" || c.Title == "commit");
            ViewData.Model = model;
            return(View());
        }
        //
        // GET: /Stability/
        public ActionResult Index()
        {
            udcEntities db = new udcEntities();
            var q =
                from s in db.Sessions
                where s.ClientSessionId != 0 // ignore welcome sessions
                where !s.IsDebug // ignore debug builds
                join tag in db.TaggedCommits on s.CommitId equals tag.CommitId
                where tag.IsRelease // only use released versions, not branch
                group new {
                    IsCrashed = s.FirstException != null,
                    IsKilled = s.EndTime == null,
                    s.StartTime,
                    CrashTime = s.FirstException ?? s.EndTime ?? s.LastFeatureUse
                } by new { s.UserId, Date = EntityFunctions.TruncateTime(s.StartTime), tag.Name };

            Debug.WriteLine(((System.Data.Objects.ObjectQuery)q).ToTraceString());
            var resultList = (
                from g in q.AsEnumerable() // don't do this on DB, EF generates too slow SQL
                group g by new { g.Key.Name } into g
                select new {
                    TagName = g.Key.Name,
                    UserDaysWithCrash = g.Count(g2 => g2.Any(s => s.IsCrashed)),
                    UserDaysWithKilled = g.Count(g2 => g2.Any(s => s.IsKilled)),
                    UserDays = g.Count(),
                    SessionsWithCrashOrKilled = g.Sum(g2 => g2.Count(s => s.IsKilled || s.IsCrashed)),
                    TotalSessionLength = g.Sum(g2 => g2.Sum(s => Math.Max(0, ((s.CrashTime - s.StartTime) ?? TimeSpan.Zero).TotalHours)))
                }
            ).OrderBy(g => g.TagName, new VersionNameComparer()).ToList();

            foreach (var item in resultList) {
                Debug.WriteLine(item.ToString());
            }

            Chart chart = new Chart();
            Series crashes = chart.Series.Add("Exceptions");
            Series killed = chart.Series.Add("Sessions without clean exit");
            crashes.ChartType = SeriesChartType.Line;
            killed.ChartType = SeriesChartType.Line;

            Chart chart2 = new Chart();
            Series crashFrequency = chart2.Series.Add("Crash Frequency");
            crashFrequency.ChartType = SeriesChartType.Line;

            foreach (var row in resultList) {
                crashes.Points.AddXY(row.TagName, 100 * (double)row.UserDaysWithCrash / row.UserDays);
                killed.Points.AddXY(row.TagName, 100 * (double)row.UserDaysWithKilled / row.UserDays);
                crashFrequency.Points.AddXY(row.TagName, row.SessionsWithCrashOrKilled / row.TotalSessionLength);
            }
            ViewData.Model = chart;
            ViewData["CrashFrequency"] = chart2;
            return View();
        }
 public static SourceControlRepository GetCached()
 {
     lock (lockObj) {
         if (cached != null && Math.Abs((cached.date - DateTime.UtcNow).TotalMinutes) < 3)
         {
             return(cached);
         }
         using (udcEntities db = new udcEntities()) {
             cached = new SourceControlRepository(db);
         }
         return(cached);
     }
 }
 public static string GetLatestTagName(int minimumAgeInDays)
 {
     using (udcEntities db = new udcEntities()) {
         DateTime minimumCommitAge = DateTime.Now.AddDays(-minimumAgeInDays);
         return((from tag in db.TaggedCommits
                 where tag.IsRelease
                 join c in db.Commits on tag.CommitId equals c.Id
                 where c.CommitDate < minimumCommitAge
                 orderby c.CommitDate descending
                 select tag.Name
                 ).FirstOrDefault());
     }
 }
        public SourceControlRepository(udcEntities db)
        {
            date = DateTime.UtcNow;
            commits = (from c in db.Commits
                       select new SourceControlCommit {
                           Id = c.Id,
                           Hash = c.Hash,
                           Date = c.CommitDate
                       }).ToDictionary(c => c.Id);

            foreach (var rel in db.CommitRelations) {
                SourceControlCommit parent = commits[rel.ParentCommit];
                SourceControlCommit child = commits[rel.ChildCommit];
                parent.Children.Add(child);
                child.Parents.Add(parent);
            }
        }
        public SourceControlRepository(udcEntities db)
        {
            date    = DateTime.UtcNow;
            commits = (from c in db.Commits
                       select new SourceControlCommit {
                Id = c.Id,
                Hash = c.Hash,
                Date = c.CommitDate
            }).ToDictionary(c => c.Id);

            foreach (var rel in db.CommitRelations)
            {
                SourceControlCommit parent = commits[rel.ParentCommit];
                SourceControlCommit child  = commits[rel.ChildCommit];
                parent.Children.Add(child);
                child.Parents.Add(parent);
            }
        }
 public static int?FindCommitId(string hashOrTagName)
 {
     if (string.IsNullOrEmpty(hashOrTagName))
     {
         return(null);
     }
     using (udcEntities db = new udcEntities()) {
         var taggedCommit = db.TaggedCommits.FirstOrDefault(c => c.Name == hashOrTagName);
         if (taggedCommit != null)
         {
             return(taggedCommit.CommitId);
         }
         Commit commit = db.Commits.FirstOrDefault(c => c.Hash.StartsWith(hashOrTagName));
         if (commit != null)
         {
             return(commit.Id);
         }
         return(null);
     }
 }
 public static int? FindCommitId(string hashOrTagName)
 {
     if (string.IsNullOrEmpty(hashOrTagName))
         return null;
     using (udcEntities db = new udcEntities()) {
         var taggedCommit = db.TaggedCommits.FirstOrDefault(c => c.Name == hashOrTagName);
         if (taggedCommit != null)
             return taggedCommit.CommitId;
         Commit commit = db.Commits.FirstOrDefault(c => c.Hash.StartsWith(hashOrTagName));
         if (commit != null)
             return commit.Id;
         return null;
     }
 }
 public static string GetLatestTagName(int minimumAgeInDays)
 {
     using (udcEntities db = new udcEntities()) {
         DateTime minimumCommitAge = DateTime.Now.AddDays(-minimumAgeInDays);
         return (from tag in db.TaggedCommits
                 where tag.IsRelease
                 join c in db.Commits on tag.CommitId equals c.Id
                 where c.CommitDate < minimumCommitAge
                 orderby c.CommitDate descending
                 select tag.Name
                ).FirstOrDefault();
     }
 }
 public static SourceControlRepository GetCached()
 {
     lock (lockObj) {
         if (cached != null && Math.Abs((cached.date - DateTime.UtcNow).TotalMinutes) < 3)
             return cached;
         using (udcEntities db = new udcEntities()) {
             cached = new SourceControlRepository(db);
         }
         return cached;
     }
 }