using InnovEnergy.Lib.S3.Metadata; using InnovEnergy.Lib.S3.Records.Specialized; using InnovEnergy.Lib.Time.Unix; using InnovEnergy.Lib.Utils; namespace InnovEnergy.Lib.S3.Drivers.Internal; public partial class Reader { public Task> ReadRecords(UnixTime from, UnixTime to, Int32 minNumber) { var maxDt = (to - from) / minNumber; return ReadRecords(from, to, maxDt); } public async Task> ReadRecords(UnixTime from, UnixTime to, UnixTimeSpan maxDt) { if (maxDt < SamplePeriod) maxDt = SamplePeriod; var level = AggregationLevels.LastOrDefault(l => l.SamplePeriod <= maxDt) ?? AggregationLevels[^1]; return await level .RangeExclusive(from, to) .Select(t => ReadRecord(level, t)) .WhenAll(); } public async Task ReadRecord(AggregationLevel level, UnixTime time) { var tsRecord = await ReadRecord(level, level.GetRetentionIndex(time)); return tsRecord.TimeStamp == time ? tsRecord : TimeStampedRecord.Empty(time); } }