Esempio n. 1
0
        private async Task MakeSureEveryDayHasAStat(DateTime endTime)
        {
            foreach (GameMode mode in Enum.GetValues(typeof(GameMode)))
            {
                var gamesPerDays = new List <GamesPerDay>();
                foreach (GateWay gw in Enum.GetValues(typeof(GateWay)))
                {
                    var stat = await _w3Stats.LoadGamesPerDay(endTime, mode, gw)
                               ?? GamesPerDay.Create(endTime, mode, gw);

                    gamesPerDays.Add(stat);
                }

                await _w3Stats.Save(gamesPerDays);
            }
        }
        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);
        }
Esempio n. 3
0
        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
            });
        }