Ejemplo n.º 1
0
        public SeasonStats GetSeasonStats(int leagueSeasonId)
        {
            OpenConnection();

            var seasonStats = Db.SeasonStats.Where(stats => stats.LeagueSeasonId == leagueSeasonId).FirstOrDefault();

            if (seasonStats == null)
            {
                seasonStats = new SeasonStats
                {
                    LeagueSeasonId = leagueSeasonId,
                    LastUpdate     = DateTime.Now
                };

                Db.SeasonStats.Add(seasonStats);
                Db.SaveChanges();

                var repo = new LogRepository();
                repo.WriteLog(Database.SystemData.Severity.Information, "Insert to SeasonStats table new record", nameof(AnalysisDataRepository),
                              "localhost", "[LeagueSeasonId = " + seasonStats.LeagueSeasonId + "]", "");
            }

            Db.Database.Connection.Close();
            return(seasonStats);
        }
Ejemplo n.º 2
0
        public void MatchDayEnd()
        {
            SeasonStats ss = new SeasonStats();

            ss.UpdateLastKnownPicks();

            List <Fixture> fixtures = new FixtureAdapter().GetFixtures(new WorldAdapter().CurrentDate);

            ss.UpdateMatchStats(fixtures);
        }
Ejemplo n.º 3
0
        public static Embed GetCompare(string StatsType, IEnumerable <Player> players, Color color)
        {
            var embedBuilder = new EmbedBuilder
            {
                Title = StatsType,
                Color = color,
                Url   = Strings.ChannelLink
            };

            //Solos
            embedBuilder.AddField(new EmbedFieldBuilder()
            {
                Name = "Solos", Value = SeasonStats.GetTitles(), IsInline = true
            });
            foreach (var player in players)
            {
                embedBuilder.AddField(new EmbedFieldBuilder()
                {
                    Name = player.Name, Value = player.SoloStats.GetListValue(), IsInline = true
                });
            }

            //Dues
            embedBuilder.AddField(new EmbedFieldBuilder()
            {
                Name = "Duos", Value = SeasonStats.GetTitles(), IsInline = true
            });
            foreach (var player in players)
            {
                embedBuilder.AddField(new EmbedFieldBuilder()
                {
                    Name = player.Name, Value = player.DuoStats.GetListValue(), IsInline = true
                });
            }

            //Squad
            embedBuilder.AddField(new EmbedFieldBuilder()
            {
                Name = "Squads", Value = SeasonStats.GetTitles(), IsInline = true
            });
            foreach (var player in players)
            {
                embedBuilder.AddField(new EmbedFieldBuilder()
                {
                    Name = player.Name, Value = player.SquadStats.GetListValue(), IsInline = true
                });
            }

            embedBuilder.WithFooter(new EmbedFooterBuilder()
            {
                Text = "با تشکر", IconUrl = "http://icons.iconarchive.com/icons/graphicloads/100-flat/256/home-icon.png"
            });
            return(embedBuilder.Build());
        }
Ejemplo n.º 4
0
        public ActionResult <SeasonStats> GetSeasonStats(int playerId)
        {
            Player player = _manager.GetPlayer(playerId);

            //TODO: Figure out how to deal with players that were not active for this season
            if (player == null || player.id == 0)
            {
                return(NotFound());
            }

            SeasonStats stats = _manager.GetShootingStats(playerId);

            return(stats != null?Ok(stats) : NotFound());
        }
Ejemplo n.º 5
0
        public void UpdateSeasonStats(SeasonStats stats)
        {
            OpenConnection();

            var seasonStats = Db.SeasonStats.Where(s => s.LeagueSeasonId == stats.LeagueSeasonId).FirstOrDefault();

            if (seasonStats != null)
            {
                seasonStats.Copy(stats);
                var repo = new LogRepository();
                repo.WriteLog(Database.SystemData.Severity.Information, "Update record in SeasonStats table", nameof(AnalysisDataRepository),
                              "localhost", "[LeagueSeasonId = " + seasonStats.LeagueSeasonId + "]", "");
                Db.SaveChanges();
            }

            Db.Database.Connection.Close();
        }
Ejemplo n.º 6
0
        public static Embed GetStats(string StatsType, SeasonStats stats, Color color)
        {
            var embedBuilder = new EmbedBuilder();

            embedBuilder.Title = StatsType;
            embedBuilder.Color = color;
            embedBuilder.Url   = "https://discord.gg/3FsMG3";

            embedBuilder.AddField(new EmbedFieldBuilder()
            {
                Name = "Title", Value = SeasonStats.GetTitles(), IsInline = true
            });
            embedBuilder.AddField(new EmbedFieldBuilder()
            {
                Name = "Title", Value = stats.GetListValue(), IsInline = true
            });

            embedBuilder.WithFooter(new EmbedFooterBuilder()
            {
                Text = "با تشکر", IconUrl = "http://icons.iconarchive.com/icons/graphicloads/100-flat/256/home-icon.png"
            });
            return(embedBuilder.Build());
        }
Ejemplo n.º 7
0
        public static Embed GetStats(string statsType, SeasonStats stats, Color color)
        {
            var embedBuilder = new EmbedBuilder
            {
                Title = statsType,
                Color = color,
                Url   = Strings.ChannelLink
            };

            embedBuilder.AddField(new EmbedFieldBuilder()
            {
                Name = Strings.Title, Value = SeasonStats.GetTitles(), IsInline = true
            });
            embedBuilder.AddField(new EmbedFieldBuilder()
            {
                Name = Strings.Title, Value = stats.GetListValue(), IsInline = true
            });

            embedBuilder.WithFooter(new EmbedFooterBuilder()
            {
                Text = Strings.Thanks, IconUrl = "http://icons.iconarchive.com/icons/graphicloads/100-flat/256/home-icon.png"
            });
            return(embedBuilder.Build());
        }
Ejemplo n.º 8
0
        public void SeasonStart()
        {
            SeasonStats ss = new SeasonStats();

            ss.ResetSeasonStatistics();
        }
Ejemplo n.º 9
0
        private void AnalyzeLeagueSeason(SeasonStats stats)
        {
            var allSeasonGames = leagueRepo.GetAllSeasonGames(stats.LeagueSeasonId);
            var analyzedGames  = systemRepo.GetSeasonStatsAnalyzedGames(stats.LeagueSeasonId);

            var processedGames = new List <int>();

            foreach (var game in allSeasonGames)
            {
                if (game.Result == 0 || analyzedGames.FindIndex(g => g.GameId == game.GameId) >= 0)
                {
                    continue;
                }
                var gameTotal = game.HomeTeamGoals + game.AwayTeamGoals;

                stats.GamePlayed++;

                if (game.Result == GameResult.HomeWin)
                {
                    stats.HomeWinsCount++;
                }
                else if (game.Result == GameResult.AwayWin)
                {
                    stats.AwayWinsCount++;
                }
                else if (game.Result == GameResult.Draw)
                {
                    stats.DrawsCount++;
                }

                stats.HomeWinsPercentage = (double)stats.HomeWinsCount / stats.GamePlayed;
                stats.AwayWinsPercentage = (double)stats.AwayWinsCount / stats.GamePlayed;
                stats.DrawsPercentage    = (double)stats.DrawsCount / stats.GamePlayed;

                stats.Goals          += gameTotal;
                stats.HomeTeamsGoals += game.HomeTeamGoals;
                stats.AwayTeamsGoals += game.AwayTeamGoals;
                stats.GoalsPerGame    = (double)stats.Goals / stats.GamePlayed;

                if (gameTotal > 2.5)
                {
                    stats.GamesOver2_5++;
                }
                else
                {
                    stats.GamesUnder2_5++;
                }

                if (game.HomeTeamGoals > 0 && game.AwayTeamGoals > 0)
                {
                    stats.BTTS_Yes++;
                }
                else
                {
                    stats.BTTS_No++;
                }

                processedGames.Add(game.GameId);
            }

            analysisRepo.UpdateSeasonStats(stats);
            systemRepo.AddAnalyzedGames_SeasonStats(processedGames, stats.LeagueSeasonId);
        }