Skip to content

Commit

Permalink
small saves
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebRose committed Oct 22, 2024
1 parent 776f0cd commit 144a2d1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
27 changes: 27 additions & 0 deletions managers/StatsManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 1 addition & 13 deletions managers/SyncManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions models/NFLDraftee.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions structs/PlayerResponses.go
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ type Croot struct {
}

type LeadingTeams struct {
TeamID uint
TeamName string
TeamAbbr string
Odds float64
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 144a2d1

Please sign in to comment.