예제 #1
0
        public static Models.v0.TeamSummaryAdvanced ToModelAdvanced(this Entities.TeamSummary entity)
        {
            if (entity == null)
            {
                return(null);
            }

            return(new Models.v0.TeamSummaryAdvanced
            {
                Team = entity.Team.ToModel(),
                Season = entity.Season,
                Games = entity.Games,
                Won = entity.Won,
                Drawn = entity.Drawn,
                Lost = entity.Lost,
                GoalsFor = entity.GoalsFor,
                GoalsAgainst = entity.GoalsAgainst,
                Points = entity.Points,
                ExpectedGoals = entity.ExpectedGoals,
                ExpectedGoalsAgainst = entity.ExpectedGoalsAgainst,
                ExpectedPoints = entity.ExpectedPoints,
                Ppda = entity.Ppda,
                DeepPasses = entity.DeepPasses,
                OppositionPpda = entity.OppositionPpda,
                OppositionDeepPasses = entity.OppositionDeepPasses,
                NonPenaltyExpectedGoals = entity.NonPenaltyExpectedGoals,
                NonPenaltyExpectedGoalsAgainst = entity.NonPenaltyExpectedGoalsAgainst
            });
        }
예제 #2
0
        public async Task ProcessTeams(List <Models.Team> teams, int season, Competition competition, IDbConnection connection)
        {
            _logger.LogInformation($"Processing {teams.Count} teams for season {season} and competition {competition.Name}");

            var teamEntities        = new List <Entities.Team>();
            var teamSummaryEntities = new List <Entities.TeamSummary>();

            foreach (var team in teams)
            {
                var teamEntity = new Entities.Team();
                teamEntity.Id        = team.Id;
                teamEntity.Name      = team.Name;
                teamEntity.ShortName = String.Empty;
                teamEntities.Add(teamEntity);

                var teamSummaryEntity = new Entities.TeamSummary();
                teamSummaryEntity.Team                           = teamEntity;
                teamSummaryEntity.Season                         = season;
                teamSummaryEntity.Competition                    = competition;
                teamSummaryEntity.Games                          = team.History.Count();
                teamSummaryEntity.Won                            = team.History.Sum(h => h.Wins);
                teamSummaryEntity.Drawn                          = team.History.Sum(h => h.Draws);
                teamSummaryEntity.Lost                           = team.History.Sum(h => h.Loses);
                teamSummaryEntity.GoalsFor                       = team.History.Sum(h => h.Scored);
                teamSummaryEntity.GoalsAgainst                   = team.History.Sum(h => h.Missed);
                teamSummaryEntity.Points                         = team.History.Sum(h => h.Points);
                teamSummaryEntity.ExpectedGoals                  = team.History.Sum(h => h.ExpectedGoals);
                teamSummaryEntity.NonPenaltyExpectedGoals        = team.History.Sum(h => h.NonPenaltyExpectedGoals);
                teamSummaryEntity.ExpectedGoalsAgainst           = team.History.Sum(h => h.ExpectedGoalsAgainst);
                teamSummaryEntity.NonPenaltyExpectedGoalsAgainst = team.History.Sum(h => h.NonPenaltyExpectedGoalsAgainst);
                teamSummaryEntity.ExpectedPoints                 = team.History.Sum(h => h.ExpectedPoints);
                teamSummaryEntity.DeepPasses                     = team.History.Sum(h => h.Deep);
                teamSummaryEntity.OppositionDeepPasses           = team.History.Sum(h => h.DeepAllowed);

                var oppositionPasses = team.History.Sum(h => h.PPDA.PassesAllowed);
                var defensiveActions = team.History.Sum(h => h.PPDA.DefensiveActions);
                teamSummaryEntity.Ppda = defensiveActions == 0 ? 0 : oppositionPasses / (double)defensiveActions;

                var passes = team.History.Sum(h => h.PPDAAllowed.PassesAllowed);
                var oppositionDefensiveActions = team.History.Sum(h => h.PPDAAllowed.DefensiveActions);
                teamSummaryEntity.OppositionPpda = oppositionDefensiveActions == 0 ? 0 : passes / (double)oppositionDefensiveActions;

                teamSummaryEntities.Add(teamSummaryEntity);
            }

            await _teamRepository.InsertMultipleAsync(teamEntities, connection);

            await _teamSummaryRepository.InsertMultipleAsync(teamSummaryEntities, connection);

            _logger.LogInformation($"Successfully processed {teams.Count} teams for season {season} and competition {competition.Name}");
        }
예제 #3
0
        public static Models.v0.TeamSummaryBasic ToModelBasic(this Entities.TeamSummary entity)
        {
            if (entity == null)
            {
                return(null);
            }

            return(new Models.v0.TeamSummaryBasic
            {
                Team = entity.Team.ToModel(),
                Season = entity.Season,
                Games = entity.Games,
                Won = entity.Won,
                Drawn = entity.Drawn,
                Lost = entity.Lost,
                GoalsFor = entity.GoalsFor,
                GoalsAgainst = entity.GoalsAgainst,
                Points = entity.Points
            });
        }