Пример #1
0
 private decimal CalculateErrorRate(int allCalls, int errorCalls)
 {
     if (allCalls == 0)
     {
         _logger.LogWarning("No calls available for error rate computation");
         return(0.0M);
     }
     return((decimal)errorCalls / (decimal)allCalls);
 }
        private decimal?ComputeAverageDuration()
        {
            var oldestEndTime   = DateTime.Now.AddHours(-24.0);
            var eligibleRecords = _dbContext.CallDurations.Where(c => c.EndTime >= oldestEndTime);

            if (!eligibleRecords.Any())
            {
                _logger.LogWarning("No records available for average duration computation.");
                return(null);
            }

            return(eligibleRecords
                   .Select(x => x.DurationMilliseconds)
                   .Average());
        }