Esempio n. 1
0
        public static Timeseries GetMonthlyAverages(string identityName)
        {
            var repo       = new RegistryEntryRepoFactory().GetRegistryEntryRepo(identityName);
            var sortedTvqs = repo.GetRegistryEntries().OrderBy(x => x.Time);

            var tsWithRegisterEntries = new Timeseries();

            tsWithRegisterEntries.AddRange(sortedTvqs.ToList());

            var periodizer      = new Periodizer();
            var monthlyAverages = periodizer.MonthlyAverage(tsWithRegisterEntries);

            //const int minMonths = 2;
            //var tooFewEntries = monthlyRegisterEntries.Count < minMonths;
            //var areTooFewEntries = tooFewEntries;
            //if (areTooFewEntries)
            //{
            //    throw new TooFewEntriesException(minMonths);
            //}

            //var deltaOperator = new DeltaTsOperator();
            //var monthlyAverages = deltaOperator.Apply(monthlyRegisterEntries);

            return(monthlyAverages);
        }
        public async Task <Timeseries> Handle(GetMonthlyAveragesCommand request, CancellationToken cancellationToken)
        {
            var repo       = _factory.GetRegistryEntryRepo(request.IdentityName);
            var sortedTvqs = (await repo.GetRegistryEntries()).OrderBy(x => x.Time);

            var tsWithRegisterEntries = new Timeseries();

            tsWithRegisterEntries.AddRange(sortedTvqs.ToList());

            var periodizer      = new Periodizer();
            var monthlyAverages = periodizer.MonthlyAverage(tsWithRegisterEntries);

            return(monthlyAverages);
        }
Esempio n. 3
0
        public static Timeseries GetMonthlyAverages(string registerId)
        {
            var storageAccount = CloudStorageAccount.Parse(
                CloudConfigurationManager.GetSetting("StorageConnectionString"));

            var repo       = new RegistryEntryRepo(storageAccount);
            var sortedTvqs = repo.GetRegistryEntries().OrderBy(x => x.Time);

            var tsWithRegisterEntries = new Timeseries();

            tsWithRegisterEntries.AddRange(sortedTvqs.ToList());

            var periodizer             = new Periodizer();
            var monthlyRegisterEntries = periodizer.MonthlyAverage(tsWithRegisterEntries);

            var deltaOperator   = new DeltaTsOperator();
            var monthlyAverages = deltaOperator.Apply(monthlyRegisterEntries);

            return(monthlyAverages);
        }
Esempio n. 4
0
 public void MonthlyAverage_WhenNull_ReturnsEmpty()
 {
     Assert.Empty(m_Periodizer.MonthlyAverage(null));
 }