private static void AppendMatchStatistics(MongoDb db) { var seasons = db.GetSeasons().ToList(); //var roundUid = GetLastCompletedRoundUid(seasons); var roundUid = new RoundUid() { Year = StartingYear, Number = 0 }; Console.WriteLine("Appending from " + roundUid.Year + ", " + roundUid.Number); //add any new matches between last match and now var api = new FootyWireApi(); foreach (var round in seasons.SelectMany(s => s.Rounds)) { if (round.Year >= 2010) { if (round.Matches.Where(m => m.HomeStats is null || m.AwayStats is null || m.HomeStats.Clearances == 0 || m.AwayStats.Clearances == 0).Count() > 0) { api.AppendMatchStatisticstoResults(round); } } else { if (round.Matches.Where(m => m.HomeStats.Kicks == 0 || m.AwayStats.Kicks == 0).Count() > 0) { api.AppendMatchStatisticstoResults(round); } } } seasons.RemoveAll(s => s.Rounds.Count == 0); //update db db.UpdateSeasons(seasons); }
private static void ExtendWBBLMatches(MongoDb db) { var seasons = db.GetWBBLSeasons().ToList(); //var year = GetLastCompletedMatch(seasons); Console.WriteLine("Extending from " + 2015); //add any new matches between last match and now var api = new WikipediaWBBLAPI(); seasons = api.UpdateFrom(2015, seasons).ToList(); seasons.RemoveAll(s => s.Matches.Count == 0); //update db db.UpdateWBBLSeasons(seasons); }
private static void UpdateMatchesWikipedia(MongoDb db) { //What have I got? var seasons = db.GetSeasons().ToList(); var roundUid = GetLastCompletedRoundUid(seasons); Console.WriteLine("Updating Matches " + roundUid.Year + ", " + roundUid.Number); //add any new matches between last match and now var api = new WikipediaApi(); seasons = api.UpdateFrom(seasons, roundUid).ToList(); seasons.RemoveAll(s => s.Rounds.Count == 0); //update db db.UpdateSeasons(seasons); }
public static void UpdateMatchesFinalSiren(MongoDb db = null) { if (db == null) { db = new MongoDb(); } //AFL var seasons = db.GetSeasons().ToList(); var roundUid = GetLastCompletedRoundUid(seasons); Console.WriteLine("Extending from " + roundUid.Year + ", " + (roundUid.IsFinal ? "Finals week " : "Round ") + roundUid.Number); //add any new matches between last match and now var api = new FinalSirenApi(); seasons = api.UpdateFrom(seasons, roundUid).ToList(); seasons.RemoveAll(s => s.Rounds.Count == 0); roundUid = GetLastCompletedRoundUid(seasons); Console.WriteLine("Last completed round: " + roundUid.Year + ", " + (roundUid.IsFinal ? "Finals week " : "Round ") + roundUid.Number); //update db db.UpdateSeasons(seasons); }
public static void LoadMainLoop() { var db = new MongoDb(); var loop = true; Console.WriteLine("AFL Statistics Service"); while (loop) { Console.Write("\n>"); var command = Console.ReadLine(); if (command == null) { continue; } switch (command.ToUpper()) { case ("A"): AppendMatchStatistics(db); break; case ("B"): Console.WriteLine("Updating BBL Matches"); ExtendBBLMatches(db); break; case ("D"): Console.WriteLine("Deleting Season"); db.DeleteSeason(2021); break; case ("F"): Console.WriteLine("Updating Matches (Footywire)"); UpdateMatchesFootyWire(); break; case ("S"): Console.WriteLine("Updating Matches (Final Siren)"); UpdateMatchesFinalSiren(); break; case ("U"): Console.WriteLine("Updating Matches (Legacy)"); UpdateMatchesFootyWire(db); break; case ("W"): Console.WriteLine("Updating Matches (Wikipedia)"); UpdateMatchesWikipedia(db); break; case ("WB"): Console.WriteLine("Updating WBBL Matches"); ExtendWBBLMatches(db); break; case ("Q"): loop = false; break; case ("?"): ListOptions(); break; } } }