void UpdateSummonerRankedStatistics(Summoner summoner, int season, AggregatedStats aggregatedStatistics, DbConnection connection) { List <ChampionStatistics> statistics = ChampionStatistics.GetChampionStatistics(aggregatedStatistics); foreach (var champion in statistics) { using (var championUpdate = Command("update summoner_ranked_statistics set wins = :wins, losses = :losses, kills = :kills, deaths = :deaths, assists = :assists, minion_kills = :minion_kills, gold = :gold, turrets_destroyed = :turrets_destroyed, damage_dealt = :damage_dealt, physical_damage_dealt = :physical_damage_dealt, magical_damage_dealt = :magical_damage_dealt, damage_taken = :damage_taken, double_kills = :double_kills, triple_kills = :triple_kills, quadra_kills = :quadra_kills, penta_kills = :penta_kills, time_spent_dead = :time_spent_dead, maximum_kills = :maximum_kills, maximum_deaths = :maximum_deaths where summoner_id = :summoner_id and season = :season and champion_id = :champion_id", connection)) { SetSummonerRankedStatisticsParameters(championUpdate, summoner, season, champion); int rowsAffected = championUpdate.Execute(); if (rowsAffected == 0) { //The champion entry didn't exist yet so we must create a new entry first string query = string.Format("insert into summoner_ranked_statistics ({0}) values ({1})", GetGroupString(SummonerRankedStatisticsFields), GetPlaceholderString(SummonerRankedStatisticsFields)); using (var championInsert = Command(query, connection)) { SetSummonerRankedStatisticsParameters(championInsert, summoner, season, champion); championInsert.Execute(); } } } } }
void RankedStatistics(List <string> arguments, bool sortByGames, bool currentOnly) { string summonerName = GetSummonerName(arguments[0]); PublicSummoner publicSummoner = RPC.GetSummonerByName(summonerName); if (publicSummoner == null) { NoSuchSummoner(); return; } string[] seasonStrings = { "CURRENT", "TWO", "ONE", }; foreach (string seasonString in seasonStrings) { Output.WriteLine("Season: \"{0}\"", seasonString); AggregatedStats aggregatedStatistics = RPC.GetAggregatedStats(publicSummoner.acctId, "CLASSIC", seasonString); if (aggregatedStatistics == null) { Output.WriteLine("Unable to retrieve aggregated statistics"); return; } List <ChampionStatistics> statistics = ChampionStatistics.GetChampionStatistics(aggregatedStatistics); foreach (var entry in statistics) { entry.Name = GetChampionName(entry.ChampionId); } if (sortByGames) { statistics.Sort(CompareChampionGames); } else { statistics.Sort(CompareChampionNames); } foreach (var entry in statistics) { Output.WriteLine("{0}: {1} {2}, {3}/{4}/{5} ({6})", entry.Name, entry.Games, entry.Games == 1 ? "game" : "games", Round(entry.KillsPerGame()), Round(entry.DeathsPerGame()), Round(entry.AssistsPerGame()), Round(entry.KillsAndAssistsPerDeath())); } if (currentOnly) { break; } } }