Ejemplo n.º 1
0
        public async Task <CourseStatistics> GetStatistics(string courseId, DateTime start, DateTime end)
        {
            var courseTask = _coursesService.FindAsync(courseId);
            var slices     = await _statisticsRepo.GetSlices(courseId, start, end);

            var(maxAge, minAge, avgAge, _) = slices.Aggregate(seed(), (curr, next) =>
            {
                var(stats, sliceSize) = next;
                return(Math.Max(curr.maxAge, stats.MaximumAge), Math.Min(curr.minAge, stats.MinimumAge), CalculateNewAverage((curr.avgAge, curr.totalSize), (stats.AverageAge, sliceSize)), curr.totalSize + sliceSize);
            });