public void GetSystemSystemStatisticsGetSystemBuildStatisticsHappyPath_Test() { //set up ------------------------------------------------------ var dbContext = this.GetDbContext(); var now = DateTime.Now; var systemStatisticsToSave = new SystemStatistics { WebsiteIsUp = true, DatabaseIsUp = true, AzureFunctionIsUp = true, Created = now }; dbContext.SystemStatistics.Add(systemStatisticsToSave); dbContext.SaveChanges(); //test --------------------------------------------------------- IBucketListData bd = new BucketListData(dbContext, this.userHelper); var systemStatistics = bd.GetSystemStatistics(); Assert.IsNotNull(systemStatistics); var systemStatistic = systemStatistics .OrderByDescending(x => Convert.ToDateTime(x.Created)) .FirstOrDefault(); Assert.AreEqual(systemStatistic.WebSiteIsUp, systemStatisticsToSave.WebsiteIsUp); Assert.AreEqual(systemStatistic.DatabaseIsUp, systemStatisticsToSave.DatabaseIsUp); Assert.AreEqual(systemStatistic.AzureFunctionIsUp, systemStatisticsToSave.AzureFunctionIsUp); Assert.AreEqual(systemStatistic.Created, systemStatisticsToSave.Created.ToString()); //clean up ------------------------------------------------------ dbContext.Remove(systemStatisticsToSave); dbContext.SaveChanges(); }
public SystemStatistics GetSystemStatistics() { var systemStatistics = new SystemStatistics(); systemStatistics.SystemStats = this.sharedWelcomeController.webClient.GetSystemStatistics(); systemStatistics.SystemBuildStats = this.sharedWelcomeController.webClient.GetSystemBuildStatistics(); return(systemStatistics); }
public void GenerateStats() { // disable caching for dev // implement caching for 1 minute string CacheKey = "Stats"; stats = (SystemStatistics)System.Web.HttpContext.Current.Cache[CacheKey]; if (System.Web.HttpContext.Current.Cache.Get(CacheKey) == null) { stats = new SystemStatistics(); System.Web.HttpContext.Current.Cache.Insert(CacheKey, stats, null, DateTime.Now.AddMinutes(1), System.Web.Caching.Cache.NoSlidingExpiration); } }
public void GenerateStats() { stats = new SystemStatistics(); // disable caching for dev // implement caching for 1 minute //Videos = (List<Video>)System.Web.HttpContext.Current.Cache[CacheKey]; //if (System.Web.HttpContext.Current.Cache.Get(CacheKey) == null) //{ // Videos = Video.GetTop100Videos((TopVideoType)TabType); // System.Web.HttpContext.Current.Cache.Insert(CacheKey, Videos, null, DateTime.Now.AddMinutes(CacheForMinutes), System.Web.Caching.Cache.NoSlidingExpiration); //} }
public virtual async Task <SystemStatistics> GetSystemStatistics() { SystemStatistics statistics = new SystemStatistics(); statistics.Soft = await _softRepository.CountAsync(); statistics.SoftUser = await _softUserRepository.CountAsync(); var sum1 = (await _financeRepository.GetAll().Where(t => t.Type == FinanceType.InCome).SumAsync(t => (decimal?)t.Money)) ?? 0; var sum2 = await _financeRepository.GetAll().Where(t => t.Type == FinanceType.InCome && t.CreationTime.Day == DateTime.Now.Day).SumAsync(t => (decimal?)t.Money) ?? 0; statistics.TotalInCome = sum1; statistics.TodayInCome = sum2; return(statistics); }