public void TestStuff() { using (GameContext context = new GameContext()) { ProPlayerItemSet itemSet = context.ItemSets.SingleOrDefault(t => t.SummonerId == SummonerIds.C9.Balls && t.ChampionId == 8); Assert.IsNotNull(itemSet); } }
public ActionResult GetItemSetJson(string summonerName, string championName) { long summonerId = SummonerIds.NameToSummonerId[summonerName]; long championId = ChampionIds.NameToId[championName]; using (GameContext context = new GameContext()) { ProPlayerItemSet itemSet = context.ItemSets.SingleOrDefault(t => t.SummonerId == summonerId && t.ChampionId == championId); if (itemSet == null) { return HttpNotFound(); } return Content(itemSet.ItemSetJson); } }
public void TestCanBeWrittenToDatabase() { var timeline = new ItemPurchaseTimeline(); timeline.AddToEndByItemId(3086, TimeSpan.Zero); timeline.AddToEndByItemId(3087, TimeSpan.FromSeconds(14)); timeline.AddToEndByItemId(3087, TimeSpan.FromSeconds(16)); var context = new GameContext(); var proGame = new ProPlayerGame(); proGame.GameId = 1; proGame.SummonerId = 5; proGame.ItemPurchaseTimeline = timeline; context.Games.Add(proGame); context.SaveChanges(); }
static void Main(string[] args) { try { var client = new RiotClient(Region.NA, new RiotClientSettings { ApiKey = ConfigurationManager.AppSettings["RiotAPIKey"] }); using (var context = new GameContext()) { foreach (var proUnderObservation in SummonerIds.Pros) { Console.WriteLine("Processing pro with summoner Id {0}", proUnderObservation); var matchList = client.GetMatchList(proUnderObservation, seasons: new Season[] { Season.SEASON2015 }, rankedQueues: new RankedQueue[] { RankedQueue.RANKED_SOLO_5x5 }); Console.WriteLine("We have info on {0} games for this pro", matchList.TotalGames); foreach (var game in matchList.Matches) { // some EUW games were causing problems (maybe region transfer?) if (game.PlatformId.Equals("NA1")) { System.Diagnostics.Debug.WriteLine("Processing game id {0}", game.MatchId); var oldItem = context.Games.SingleOrDefault((t) => t.SummonerId == proUnderObservation && t.GameId == game.MatchId); //var oldItem = context.Games.Find(proUnderObservation, game.MatchId); if (oldItem == null) // not in database already { var singleMatch = client.GetMatch(game.MatchId, true); var itemListFromSingleMatch = new ItemPurchaseTimeline(singleMatch, proUnderObservation); var championId = game.Champion; var proPlayerGame = new ProPlayerGame(proUnderObservation, game.MatchId, championId, itemListFromSingleMatch); context.Games.Add(proPlayerGame); context.SaveChanges(); } } } } } } catch(Exception e) { // may not always have a debugger Console.WriteLine(e); throw e; } }
public ActionResult Index() { long summonerId = SummonerIds.C9.Balls; long championId = 8; using (GameContext context = new GameContext()) { ProPlayerItemSet itemSet = context.ItemSets.SingleOrDefault(t => t.SummonerId == summonerId && t.ChampionId == championId); if (itemSet == null) { // return Content(string.Format("Cannot find item set with SummonerId {0} and ChampionId {1}", summonerId, championId)); return View("Index"); } return View("ItemSetJson", itemSet); } }
static void Main(string[] args) { using (var context = new GameContext()) { var summonerIdsInTable = (from y in context.Games select y.SummonerId).Distinct().ToList(); Console.WriteLine("There are {0} summoners in the database", summonerIdsInTable.Count()); foreach (var proPlayerSummonerId in summonerIdsInTable) { Console.WriteLine("Running through summoner id {0}", proPlayerSummonerId); // we will only even both to run any algorithm to try an generate // an item set if the pro has more than 5 games on the champion var listOfGamesAccordingToChampion = (from x in context.Games where x.SummonerId == proPlayerSummonerId group x by x.ChampionId into champLists where champLists.Count() >= 5 select champLists).ToList(); // the champList contains all games this pro played with 1 particular champ foreach (var champList in listOfGamesAccordingToChampion) { Console.WriteLine("Running through champ id {0}", champList.Key); Console.WriteLine("Games count on this champ is is {0}", champList.Count()); var dbScanList = new List<DBScanProPlayerGame>(); foreach (var game in champList) { System.Diagnostics.Debug.WriteLine("Game Id is {0}", game.GameId); var dbScanProPlayerGame = new DBScanProPlayerGame(game); dbScanList.Add(dbScanProPlayerGame); } Console.WriteLine("Running DBScan on games"); var dbScan = new DBScan(); var clusters = dbScan.GetClusters(dbScanList, 5, 3); foreach (var oneCluster in clusters) { Console.WriteLine("Cluster of count {0} identified", oneCluster.Count); } if (clusters.Count != 0) { Console.WriteLine("Trying to find biggest cluster"); var biggestCluster = (from cluster in clusters orderby cluster.Count select cluster).First(); var centerOfBiggestCluster = dbScan.FindCenterOfCluster(biggestCluster); var timelineFromCenter = centerOfBiggestCluster.Game.ItemPurchaseTimeline; var itemBlocks = timelineFromCenter.TryToSplitIntoPurchases(15); var itemSet = new ItemSet("Item Set", itemBlocks); var itemSetJson = itemSet.ToJson(); Console.WriteLine("Generated item set with json\n{0}", itemSetJson); var oldItem = context.ItemSets.SingleOrDefault((t) => t.SummonerId == proPlayerSummonerId && t.ChampionId == champList.Key); //var oldItem = context.ItemSets.Find(proPlayerSummonerId, champList.Key); if (oldItem != null) { oldItem.ItemSetJson = itemSetJson; } else { context.ItemSets.Add(new ProPlayerItemSet(proPlayerSummonerId, champList.Key, itemSetJson)); } } else { Console.WriteLine("No clusters found"); } } } context.SaveChanges(); } }