private MonthProjectStats CreateBlankMonthProjectStats(TimeSpan utcOffset, DateTime localDate, string projectId, string errorStackId = null, bool isNew = false) { var dayStats = new Dictionary<string, ErrorStatsWithStackIds>(); int daysInMonth = DateTime.DaysInMonth(localDate.Year, localDate.Month); bool hasError = !String.IsNullOrEmpty(errorStackId); for (int i = 1; i <= daysInMonth; i++) { var stat = new ErrorStatsWithStackIds(); if (hasError && i == localDate.Day) { stat.Total = 1; stat.NewTotal = isNew ? 1 : 0; stat.ErrorStackIds.Add(errorStackId, 1); if (isNew) stat.NewErrorStackIds.Add(errorStackId); dayStats.Add(i.ToString(), stat); } } string id = GetMonthProjectStatsId(localDate, utcOffset, projectId); var s = new MonthProjectStats { Id = id, ProjectId = projectId, Total = hasError ? 1 : 0, NewTotal = isNew ? 1 : 0, DayStats = dayStats }; if (hasError) s.ErrorStackIds.Add(errorStackId, 1); if (hasError && isNew) s.NewErrorStackIds.Add(errorStackId); return s; }
private DayProjectStats CreateBlankDayProjectStats(DateTime occurrenceDate, string projectId, string errorStackId = null, bool isNew = false) { bool hasError = !String.IsNullOrEmpty(errorStackId); // store stats in 15 minute buckets var bucketStats = new Dictionary<string, ErrorStatsWithStackIds>(); for (int i = 0; i < 1440; i += 15) { var stat = new ErrorStatsWithStackIds(); if (hasError && i == GetTimeBucket(occurrenceDate)) { stat.Total = 1; stat.NewTotal = isNew ? 1 : 0; stat.ErrorStackIds.Add(errorStackId, 1); if (isNew) stat.NewErrorStackIds.Add(errorStackId); bucketStats.Add(i.ToString("0000"), stat); } } var s = new DayProjectStats { Id = GetDayProjectStatsId(projectId, occurrenceDate), ProjectId = projectId, Total = hasError ? 1 : 0, NewTotal = isNew ? 1 : 0, MinuteStats = bucketStats }; if (hasError) s.ErrorStackIds.Add(errorStackId, 1); if (isNew) s.NewErrorStackIds.Add(errorStackId); return s; }