Ejemplo n.º 1
0
        private MonthProjectStats CreateBlankMonthProjectStats(TimeSpan utcOffset, DateTime localDate, string projectId, string stackId = null, bool isNew = false)
        {
            var  dayStats    = new Dictionary <string, EventStatsWithStackIds>();
            int  daysInMonth = DateTime.DaysInMonth(localDate.Year, localDate.Month);
            bool hasEvent    = !String.IsNullOrEmpty(stackId);

            for (int i = 1; i <= daysInMonth; i++)
            {
                var stat = new EventStatsWithStackIds();
                if (hasEvent && i == localDate.Day)
                {
                    stat.Total    = 1;
                    stat.NewTotal = isNew ? 1 : 0;
                    stat.StackIds.Add(stackId, 1);
                    if (isNew)
                    {
                        stat.NewStackIds.Add(stackId);
                    }

                    dayStats.Add(i.ToString(), stat);
                }
            }

            string id = GetMonthProjectStatsId(localDate, utcOffset, projectId);
            var    s  = new MonthProjectStats {
                Id        = id,
                ProjectId = projectId,
                Total     = hasEvent ? 1 : 0,
                NewTotal  = isNew ? 1 : 0,
                DayStats  = dayStats
            };

            if (hasEvent)
            {
                s.StackIds.Add(stackId, 1);
            }

            if (hasEvent && isNew)
            {
                s.NewStackIds.Add(stackId);
            }

            return(s);
        }
Ejemplo n.º 2
0
        private DayProjectStats CreateBlankDayProjectStats(DateTime occurrenceDate, string projectId, string stackId = null, bool isNew = false)
        {
            bool hasEvent = !String.IsNullOrEmpty(stackId);

            // store stats in 15 minute buckets
            var bucketStats = new Dictionary <string, EventStatsWithStackIds>();

            for (int i = 0; i < 1440; i += 15)
            {
                var stat = new EventStatsWithStackIds();
                if (hasEvent && i == GetTimeBucket(occurrenceDate))
                {
                    stat.Total    = 1;
                    stat.NewTotal = isNew ? 1 : 0;
                    stat.StackIds.Add(stackId, 1);
                    if (isNew)
                    {
                        stat.NewStackIds.Add(stackId);
                    }

                    bucketStats.Add(i.ToString("0000"), stat);
                }
            }

            var s = new DayProjectStats {
                Id          = GetDayProjectStatsId(projectId, occurrenceDate),
                ProjectId   = projectId,
                Total       = hasEvent ? 1 : 0,
                NewTotal    = isNew ? 1 : 0,
                MinuteStats = bucketStats
            };

            if (hasEvent)
            {
                s.StackIds.Add(stackId, 1);
            }
            if (isNew)
            {
                s.NewStackIds.Add(stackId);
            }

            return(s);
        }