private async Task GetRiotMatchupInformationAndAddIfNotExisting(IBasicMatchupInformationRepository matchupInformationRepository, MatchList matchlist, IEnumerable <LeaguePosition> highEloPlayerEntires) { foreach (var match in matchlist?.Matches) { if (match.Queue == LeagueQueue.RankedSoloId && matchupInformationRepository.GetMatchupByGameId(match.GameId) == null) { Match riotMatchInformation = await _throttledRequestHelper.SendThrottledRequest <Match>(async() => await _riotApi.Match.GetMatchAsync(RiotSharp.Misc.Region.euw, match.GameId)); if (riotMatchInformation != null & riotMatchInformation?.Participants != null) { var winningTeamId = riotMatchInformation.Teams.Find(x => x.Win == MatchOutcome.Win).TeamId; List <Db_LccBasicMatchInfoPlayer> winningTeam = new List <Db_LccBasicMatchInfoPlayer>(); List <Db_LccBasicMatchInfoPlayer> losingTeam = new List <Db_LccBasicMatchInfoPlayer>(); foreach (Participant player in riotMatchInformation.Participants) { Player matchPlayer = riotMatchInformation.ParticipantIdentities.FirstOrDefault(x => x.ParticipantId == player.ParticipantId).Player; Db_LccBasicMatchInfoPlayer lccMatchupInformationPlayer = new Db_LccBasicMatchInfoPlayer() { ChampionId = player.ChampionId, Lane = player.Timeline.Lane, PlayerAccountId = matchPlayer.AccountId, SummonerName = matchPlayer.SummonerName }; if (player.TeamId == winningTeamId) { winningTeam.Add(lccMatchupInformationPlayer); } else { losingTeam.Add(lccMatchupInformationPlayer); } } matchupInformationRepository.InsertMatchup( new Db_LccBasicMatchInfo() { GameId = match.GameId, MatchDate = match.Timestamp, WinningTeamChampions = winningTeam, LosingTeamChampions = losingTeam }); matchesUpdatedTotal++; matchesUpdatedThisSession++; _logging.LogEvent("Added new matchup No:" + matchesUpdatedTotal); } } } }
public MatchController(IRiotApi riotApi, IBasicMatchupInformationRepository matchupInformationRepository, ICachedCalculatedMatchupInformationRepository cachedCalculatedMatchupInformaton, IMatchControllerUtils matchControllerUtils) { _riotApi = riotApi; _matchupInformationRepository = matchupInformationRepository; _cachedCalculatedMatchupInformaton = cachedCalculatedMatchupInformaton; _matchControllerUtils = matchControllerUtils; }