Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public static void UpdateMatchesFootyWire(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 FootyWireApi();

            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);
        }