Skip to content

Optimizing obtaining most played champions in last 100 games #704

@hermderger

Description

@hermderger

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions