public async Task Update(MatchFinishedEvent nextEvent) { if (nextEvent.WasFakeEvent) { return; } var match = nextEvent.match; var endTime = DateTimeOffset.FromUnixTimeMilliseconds(match.endTime).Date; var stat = await _w3Stats.LoadGamesPerDay(endTime, match.gameMode) ?? GamesPerDay.Create(endTime, match.gameMode); var statOverall = await _w3Stats.LoadGamesPerDay(endTime, GameMode.Undefined) ?? GamesPerDay.Create(endTime, GameMode.Undefined); stat.AddGame(); statOverall.AddGame(); await _w3Stats.Save(stat); await _w3Stats.Save(statOverall); }
public async Task Update(MatchFinishedEvent nextEvent) { if (nextEvent.WasFakeEvent) { return; } var match = nextEvent.match; var endTime = DateTimeOffset.FromUnixTimeMilliseconds(match.endTime).Date; await MakeSureEveryDayHasAStat(endTime); var stat = await _w3Stats.LoadGamesPerDay(endTime, match.gameMode, match.gateway) ?? GamesPerDay.Create(endTime, match.gameMode, match.gateway); var statOverallForGateway = await _w3Stats.LoadGamesPerDay(endTime, GameMode.Undefined, match.gateway) ?? GamesPerDay.Create(endTime, GameMode.Undefined, match.gateway); var statForGameModeOnAllGateways = await _w3Stats.LoadGamesPerDay(endTime, match.gameMode, GateWay.Undefined) ?? GamesPerDay.Create(endTime, match.gameMode, GateWay.Undefined); var statOverall = await _w3Stats.LoadGamesPerDay(endTime, GameMode.Undefined, GateWay.Undefined) ?? GamesPerDay.Create(endTime, GameMode.Undefined, GateWay.Undefined); stat.AddGame(); statOverall.AddGame(); statOverallForGateway.AddGame(); statForGameModeOnAllGateways.AddGame(); await _w3Stats.Save(new List <GamesPerDay> { stat, statOverall, statOverallForGateway, statForGameModeOnAllGateways }); }