diff --git a/managers/StatsManager.go b/managers/StatsManager.go index 65cd0f8..6c3dd53 100644 --- a/managers/StatsManager.go +++ b/managers/StatsManager.go @@ -558,6 +558,33 @@ func ResetCFBSeasonalStats() { fmt.Println("Reset Season Stats for " + player.FirstName + " " + player.LastName + " " + player.Position) } + historicPlayers := GetAllHistoricCollegePlayers() + for _, player := range historicPlayers { + playerID := strconv.Itoa(int(player.ID)) + playerStats := GetCollegePlayerStatsByPlayerIDAndSeason(playerID, seasonID) + if len(playerStats) > 0 { + seasonStats := GetCollegeSeasonStatsByPlayerAndSeason(playerID, seasonID) + if len(playerStats) == seasonStats.GamesPlayed { + continue + } + seasonStats.ResetStats() + seasonStats.MapStats(playerStats) + db.Save(&seasonStats) + } + + playerSnaps := GetCollegePlayerSnapsByPlayerIDAndSeason(playerID, seasonID) + if len(playerSnaps) > 0 { + seasonSnaps := GetCollegeSeasonSnapsByPlayerAndSeason(playerID, seasonID) + seasonSnaps.Reset() + for _, s := range playerSnaps { + seasonSnaps.AddToSeason(s.BasePlayerGameSnaps) + } + repository.SaveCFBSeasonSnaps(seasonSnaps, db) + } + + fmt.Println("Reset Season Stats for " + player.FirstName + " " + player.LastName + " " + player.Position) + } + standings := GetAllConferenceStandingsBySeasonID(seasonID) for _, standing := range standings { diff --git a/managers/SyncManager.go b/managers/SyncManager.go index 672fa0c..06da280 100644 --- a/managers/SyncManager.go +++ b/managers/SyncManager.go @@ -322,24 +322,12 @@ func SyncRecruitingEfficiency(timestamp structs.Timestamp) { // RES Calculation // Base of .8 - teamProfile.AssignRES(res + (totalSum * 0.4)) - - err := db.Save(&teamProfile).Error - if err != nil { - fmt.Println(err.Error()) - log.Fatalf("Could not sync all team profiles.") - } + repository.SaveRecruitingTeamProfile(teamProfile, db) fmt.Println("Saved RES for Team: " + team.TeamAbbr) - // teamProfilesToSave = append(teamProfilesToSave, teamProfile) } // Save the Recruiting Profiles - // err = db.Save(&recruitProfilesToSave).Error - // if err != nil { - // fmt.Println(err.Error()) - // log.Fatalf("Could not sync res to all recruits") - // } } func SyncAllMissingEfficiencies() { diff --git a/models/NFLDraftee.go b/models/NFLDraftee.go index 0feaf39..f112d06 100644 --- a/models/NFLDraftee.go +++ b/models/NFLDraftee.go @@ -53,6 +53,7 @@ func (n *NFLDraftee) Map(cp structs.CollegePlayer) { n.PlayerID = cp.PlayerID n.HighSchool = cp.HighSchool n.College = cp.TeamAbbr + n.CollegeID = uint(cp.TeamID) n.City = cp.City n.State = cp.State n.FirstName = cp.FirstName diff --git a/structs/PlayerResponses.go b/structs/PlayerResponses.go index 2d9a8ae..23a4b95 100644 --- a/structs/PlayerResponses.go +++ b/structs/PlayerResponses.go @@ -944,6 +944,7 @@ type Croot struct { } type LeadingTeams struct { + TeamID uint TeamName string TeamAbbr string Odds float64 @@ -1025,6 +1026,7 @@ func (c *Croot) Map(r Recruit) { odds = float64(sortedProfiles[i].TotalPoints) / totalPoints } leadingTeam := LeadingTeams{ + TeamID: uint(r.RecruitPlayerProfiles[i].ProfileID), TeamAbbr: r.RecruitPlayerProfiles[i].TeamAbbreviation, Odds: odds, HasScholarship: r.RecruitPlayerProfiles[i].Scholarship,