diff --git a/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs b/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs index f83932db..b8b11639 100644 --- a/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs +++ b/AsbCloudInfrastructure/Services/DataSaubStatDrillingQualityService.cs @@ -126,20 +126,20 @@ public class DataSaubStatDrillingQualityService : IDataSaubStatDrillingQualitySe while (indexEnd < dataSaub.Count() - 1) { - indexStart = Array.FindIndex(dataSaub, indexEnd, t => t.IdFeedRegulator == idFeedRegulator); - if (indexStart < 0) - break; + indexStart = Array.FindIndex(dataSaub, indexEnd, t => t.IdFeedRegulator == idFeedRegulator); + if (indexStart < 0 || indexStart == dataSaub.Count() - 1) + break; - indexEnd = FindIndexEnd(indexStart, idFeedRegulator, dataSaub); + indexEnd = FindIndexEnd(indexStart, idFeedRegulator, dataSaub); - var length = indexEnd - indexStart + 1; - var subset = dataSaub.AsSpan(indexStart, length); + var length = indexEnd - indexStart + 1; + var subset = dataSaub.AsSpan(indexStart, length); - if ((subset[^1].WellDepth - subset[0].WellDepth) < 0.15) - continue; // мелкие выборки не учитываем. + if ((subset[^1].WellDepth - subset[0].WellDepth) < 0.15) + continue; // мелкие выборки не учитываем. - var stats = CalcStatsDrillingQuality(idFeedRegulator, subset, checkQuality); - result.Add(stats); + var stats = CalcStatsDrillingQuality(idFeedRegulator, subset, checkQuality); + result.Add(stats); } return result;