public async Task <GuestAccountInfo> ReadAccountInfoAndPutInCache(long accountId) { var guestAccountInfo = new GuestAccountInfo(); await _statisticsCollectorEngine.Collect( _statisticsCollectorFactory.CreateCollector(accountId, guestAccountInfo)); string cacheKey = string.Format(CacheKeyTemplate, accountId); _cache.Set <GuestAccountInfo>(cacheKey, guestAccountInfo, TimeSpan.FromMinutes(10)); return(guestAccountInfo); }
public async Task TestWholeCollectOperation() { SetInitialData(); await _statisticsCollectorEngine.Collect( _statisticsCollectorFactory.CreateCollector(_dataStubs.AccountInfo.AccountId)); var accounts = _dbContext.AccountInfo.AsNoTracking().ToList(); Assert.NotNull(accounts); Assert.Single(accounts); Assert.Equal(_dataStubs.WargamingAccountInfo.AccountId, accounts.Single().AccountId); Assert.Equal(_dataStubs.WargamingAccountInfo.LastBattleTime, accounts.Single().LastBattleTime); Assert.Equal(_dataStubs.AccountInfo.AccessTokenExpiration, accounts.Single().AccessTokenExpiration); var accountStat = _dbContext.AccountInfoStatistics.AsNoTracking().ToList(); Assert.NotNull(accountStat); Assert.Single(accountStat); var wgStat = _dataStubs.WargamingAccountInfo.AccountInfoStatistics.Single(); Assert.Equal(wgStat.AccountId, accountStat.Single().AccountId); Assert.Equal(wgStat.Battles, accountStat.Single().Battles); Assert.Equal(wgStat.UpdatedAt, accountStat.Single().UpdatedAt); var accountFrags = _dbContext.Frags.AsNoTracking().Where(f => f.TankId == null).ToList(); Assert.NotNull(accountFrags); Assert.Equal(wgStat.FragsList.Count, accountFrags.Count); var clanInfo = _dbContext.AccountClanInfo.AsNoTracking().ToList(); Assert.NotNull(clanInfo); Assert.Single(clanInfo); Assert.Equal(_dataStubs.AccountClanInfo.AccountId, clanInfo.Single().AccountId); Assert.Equal(_dataStubs.AccountClanInfo.ClanTag, clanInfo.Single().ClanTag); var clanHistory = _dbContext.AccountClanHistory.AsNoTracking().ToList(); Assert.NotNull(clanHistory); Assert.Single(clanHistory); Assert.Equal(_dataStubs.AccountClanInfo.AccountId, clanHistory.Single().AccountId); Assert.Equal(_dataStubs.AccountClanInfo.ClanTag, clanHistory.Single().ClanTag); var accounAchievemnts = _dbContext.AccountInfoTankAchievement.AsNoTracking().ToList(); Assert.NotNull(accounAchievemnts); Assert.Equal(_dataStubs.AccountInfoAchievements.Count, accounAchievemnts.Where(a => a.TankId == 0).ToList().Count); Assert.Equal(_dataStubs.AccountInfoTankAchievements.Count, accounAchievemnts.Where(a => a.TankId > 0).ToList().Count); var tanksStat = _dbContext.PresentAccountTanks.AsNoTracking() .Join(_dbContext.AccountTankStatistics, p => p.AccountTankStatisticId, t => t.AccountTankStatisticId, (p, t) => new { AccountTankStatistics = t }) .ToList(); Assert.NotNull(tanksStat); Assert.Equal(_dataStubs.AccountTanksStatistics.Count, tanksStat.Count); }
public async Task <IActionResult> Index() { await _statisticsCollectorEngine.Collect(_statisticsCollectorFactory.CreateCollector()); return(Ok()); }