-
Notifications
You must be signed in to change notification settings - Fork 144
Open
Description
Is there a more efficient way to obtain the top 6 most played champions of a summoner using their Summoner Name and Region from their last 100 games?
Here is what I am currently using but it's very slow:
List<int> playedChampionIds = new List<int>();
summoner = api.Summoner.GetSummonerByNameAsync(selectedSpecificRegion, name).Result;
var matchListOfSummoner = api.Match.GetMatchListAsync(selectedBroadRegion, summoner.Puuid, null, 100).Result;
foreach (var m in matchListOfSummoner)
{
var matchData = api.Match.GetMatchAsync(selectedBroadRegion, m).Result;
var summonerMatchData = matchData.Info.Participants.FirstOrDefault(p => p.SummonerId == summoner.Id);
if (summonerMatchData != null)
{
playedChampionIds.Add(summonerMatchData.ChampionId);
}
}
var mostPlayed = (from c in playedChampionIds
group c by c into grp
orderby grp.Count() descending
select grp.Key).Take(6);
Metadata
Metadata
Assignees
Labels
No labels