Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 39 additions & 19 deletions controller/CronController.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ func SyncFreeAgencyViaCron() {

func SyncToNextWeekViaCron() {
ts := managers.GetTimestamp()
if !ts.RunGames {
return
}
if ts.RunCron {
if !ts.IsOffSeason && !ts.IsNFLOffSeason {
ts = managers.MoveUpWeek()
Expand Down Expand Up @@ -117,6 +120,11 @@ func RunTheGamesViaCron() {

func ShowCFBThursdayViaCron() {
ts := managers.GetTimestamp()

if !ts.RunGames {
return
}

timeslot := ""
if !ts.ThursdayGames {
timeslot = "Thursday Night"
Expand All @@ -128,6 +136,9 @@ func ShowCFBThursdayViaCron() {

func ShowNFLThursdayViaCron() {
ts := managers.GetTimestamp()
if !ts.RunGames {
return
}
timeslot := ""
if !ts.NFLThursday {
timeslot = "Thursday Night Football"
Expand All @@ -139,6 +150,9 @@ func ShowNFLThursdayViaCron() {

func ShowCFBFridayViaCron() {
ts := managers.GetTimestamp()
if !ts.RunGames {
return
}
timeslot := ""
if !ts.FridayGames {
timeslot = "Friday Night"
Expand All @@ -150,6 +164,9 @@ func ShowCFBFridayViaCron() {

func ShowCFBSatMornViaCron() {
ts := managers.GetTimestamp()
if !ts.RunGames {
return
}
timeslot := ""
if !ts.SaturdayMorning {
timeslot = "Saturday Morning"
Expand All @@ -161,6 +178,9 @@ func ShowCFBSatMornViaCron() {

func ShowCFBSatAftViaCron() {
ts := managers.GetTimestamp()
if !ts.RunGames {
return
}
timeslot := ""
if !ts.SaturdayNoon {
timeslot = "Saturday Afternoon"
Expand All @@ -172,6 +192,9 @@ func ShowCFBSatAftViaCron() {

func ShowCFBSatEveViaCron() {
ts := managers.GetTimestamp()
if !ts.RunGames {
return
}
timeslot := ""
if !ts.SaturdayEvening {
timeslot = "Saturday Evening"
Expand All @@ -183,27 +206,12 @@ func ShowCFBSatEveViaCron() {

func ShowCFBSatNitViaCron() {
ts := managers.GetTimestamp()
if !ts.RunGames {
return
}
timeslot := ""
if !ts.ThursdayGames {
timeslot = "Thursday Night"
} else if !ts.NFLThursday {
timeslot = "Thursday Night Football"
} else if !ts.SaturdayMorning {
timeslot = "Saturday Morning"
} else if !ts.SaturdayNoon {
timeslot = "Saturday Afternoon"
} else if !ts.SaturdayEvening {
timeslot = "Saturday Evening"
} else if !ts.SaturdayNight {
if !ts.SaturdayNight {
timeslot = "Saturday Night"
} else if !ts.NFLSundayNoon {
timeslot = "Sunday Noon"
} else if !ts.NFLSundayAfternoon {
timeslot = "Sunday Afternoon"
} else if !ts.NFLSundayEvening {
timeslot = "Sunday Night Football"
} else if !ts.NFLMondayEvening {
timeslot = "Monday Night Football"
}
if ts.RunCron && (!ts.IsOffSeason || !ts.IsNFLOffSeason || !ts.CollegeSeasonOver || !ts.NFLSeasonOver) {
managers.SyncTimeslot(timeslot)
Expand All @@ -212,6 +220,9 @@ func ShowCFBSatNitViaCron() {

func ShowNFLSunNoonViaCron() {
ts := managers.GetTimestamp()
if !ts.RunGames {
return
}
timeslot := ""
if !ts.NFLSundayNoon {
timeslot = "Sunday Noon"
Expand All @@ -223,6 +234,9 @@ func ShowNFLSunNoonViaCron() {

func ShowNFLSunAftViaCron() {
ts := managers.GetTimestamp()
if !ts.RunGames {
return
}
timeslot := ""
if !ts.NFLSundayAfternoon {
timeslot = "Sunday Afternoon"
Expand All @@ -234,6 +248,9 @@ func ShowNFLSunAftViaCron() {

func ShowNFLSunNitViaCron() {
ts := managers.GetTimestamp()
if !ts.RunGames {
return
}
timeslot := ""
if !ts.NFLSundayEvening {
timeslot = "Sunday Night Football"
Expand All @@ -245,6 +262,9 @@ func ShowNFLSunNitViaCron() {

func ShowNFLMonNitViaCron() {
ts := managers.GetTimestamp()
if !ts.RunGames {
return
}
timeslot := ""
if !ts.NFLMondayEvening {
timeslot = "Monday Night Football"
Expand Down
8 changes: 6 additions & 2 deletions controller/ImportController.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ func ImportCFBStandings(w http.ResponseWriter, r *http.Request) {
managers.ImportSeasonStandings()
}

func ImportCFBGames(w http.ResponseWriter, r *http.Request) {
managers.ImportCFBGames()
func ImportCFBRegularSeasonGames(w http.ResponseWriter, r *http.Request) {
managers.ImportCFBGames(false)
}

func ImportCFBSpringGames(w http.ResponseWriter, r *http.Request) {
managers.ImportCFBGames(true)
}

func ImportNFLGames(w http.ResponseWriter, r *http.Request) {
Expand Down
159 changes: 81 additions & 78 deletions data/2026/2026_cfb_games_preseason.csv

Large diffs are not rendered by default.

1,585 changes: 1,585 additions & 0 deletions data/2026/2026_cfb_games_regular.csv

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ func handleRequests() http.Handler {
// apiRouter.HandleFunc("/admin/import/nfl/draft", controller.Import2023DraftedPlayers).Methods("GET")
// apiRouter.HandleFunc("/admin/import/cfb/standings", controller.ImportCFBStandings).Methods("GET")
// apiRouter.HandleFunc("/admin/import/cfb/coaches", controller.GenerateCoachesForAITeams).Methods("GET")
// apiRouter.HandleFunc("/admin/import/cfb/games", controller.ImportCFBGames).Methods("GET")
// apiRouter.HandleFunc("/admin/import/cfb/games", controller.ImportCFBGames).Methods("GET")
// apiRouter.HandleFunc("/admin/import/cfb/regular/games", controller.ImportCFBRegularSeasonGames).Methods("GET")
// apiRouter.HandleFunc("/admin/import/cfb/spring/games", controller.ImportCFBSpringGames).Methods("GET")
// apiRouter.HandleFunc("/admin/import/cfb/rivals", controller.ImportCFBRivals).Methods("GET")
// apiRouter.HandleFunc("/admin/import/cfb/teams", controller.ImportCFBTeams).Methods("GET")
// apiRouter.HandleFunc("/admin/import/nfl/games", controller.ImportNFLGames).Methods("GET")
Expand Down
3 changes: 0 additions & 3 deletions managers/GameplanManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,6 @@ func UpdateCollegeAIDepthChartsTEST() {
db := dbprovider.GetInstance().GetDB()
teams := GetAllCollegeTeams()
for _, team := range teams {
// if len(team.Coach) > 0 && team.Coach != "AI" {
// continue
// }

teamID := strconv.Itoa(int(team.ID))
gp := GetGameplanTESTByTeamID(teamID)
Expand Down
22 changes: 12 additions & 10 deletions managers/ImportManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,17 +554,17 @@ func ImportUDFAs() {
}
}

func ImportCFBGames() {
func ImportCFBGames(isSpringGames bool) {
db := dbprovider.GetInstance().GetDB()

path := "C:\\Users\\ctros\\go\\src\\github.com\\CalebRose\\SimFBA\\data\\2026\\2026_cfb_games_preseason.csv"
path := "C:\\Users\\ctros\\go\\src\\github.com\\CalebRose\\SimFBA\\data\\2026\\2026_cfb_games_regular.csv"

gamesCSV := util.ReadCSV(path)

ts := GetTimestamp()

teamMap := make(map[string]structs.CollegeTeam)

games := []structs.CollegeGame{}

allCollegeTeams := GetAllCollegeTeams()

for _, t := range allCollegeTeams {
Expand All @@ -580,7 +580,7 @@ func ImportCFBGames() {
season := util.ConvertStringToInt(row[1])
seasonID := season - 2020
week := util.ConvertStringToInt(row[2])
weekID := week + 88 // Week 43 is week 0 of the 2023 Season
weekID := util.GetWeekID(uint(seasonID), uint(week))
homeTeamAbbr := row[3]
awayTeamAbbr := row[4]
ht := teamMap[homeTeamAbbr]
Expand All @@ -596,8 +596,8 @@ func ImportCFBGames() {
state := row[19]
isDomed := util.ConvertStringToBool(row[20])
// Need to check for if a game is in a domed stadium or not
isConferenceGame := ht.ConferenceID == at.ConferenceID
isDivisionGame := isConferenceGame && ht.DivisionID == at.DivisionID && ht.DivisionID > 0
isConferenceGame := !isSpringGames && ht.ConferenceID == at.ConferenceID
isDivisionGame := !isSpringGames && isConferenceGame && ht.DivisionID == at.DivisionID && ht.DivisionID > 0
conferenceID := 0
if isConferenceGame {
conferenceID = ht.ConferenceID
Expand All @@ -616,7 +616,7 @@ func ImportCFBGames() {
game := structs.CollegeGame{
Model: gorm.Model{ID: uint(gameID)},
SeasonID: seasonID,
WeekID: weekID,
WeekID: int(weekID),
Week: week,
HomeTeamID: int(homeTeamID),
AwayTeamID: int(awayTeamID),
Expand All @@ -625,7 +625,7 @@ func ImportCFBGames() {
HomeTeamCoach: homeTeamCoach,
AwayTeamCoach: awayTeamCoach,
IsConferenceChampionship: isConferenceChampionship,
IsSpringGame: ts.CFBSpringGames,
IsSpringGame: isSpringGames,
IsBowlGame: isBowlGame,
IsNeutral: isNeutralSite,
IsPlayoffGame: isPlayoffGame,
Expand All @@ -645,8 +645,10 @@ func ImportCFBGames() {
ConferenceID: uint(conferenceID),
}

db.Create(&game)
games = append(games, game)
}
repository.CreateCFBGameRecordsBatch(db, games, 250)

GenerateWeatherForGames()
}

Expand Down
31 changes: 31 additions & 0 deletions repository/GamesRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package repository
import (
"github.com/CalebRose/SimFBA/dbprovider"
"github.com/CalebRose/SimFBA/structs"
"gorm.io/gorm"
)

func FindCollegeGamesRecords(SeasonID string, isSpringGames bool) []structs.CollegeGame {
Expand Down Expand Up @@ -38,3 +39,33 @@ func FindNFLGamesRecords(SeasonID string, isSpringGames bool) []structs.NFLGame
}
return games
}

func CreateCFBGameRecordsBatch(db *gorm.DB, games []structs.CollegeGame, batchSize int) error {
total := len(games)
for i := 0; i < total; i += batchSize {
end := i + batchSize
if end > total {
end = total
}

if err := db.CreateInBatches(games[i:end], batchSize).Error; err != nil {
return err
}
}
return nil
}

func CreateNFLGameRecordsBatch(db *gorm.DB, games []structs.NFLGame, batchSize int) error {
total := len(games)
for i := 0; i < total; i += batchSize {
end := i + batchSize
if end > total {
end = total
}

if err := db.CreateInBatches(games[i:end], batchSize).Error; err != nil {
return err
}
}
return nil
}
6 changes: 6 additions & 0 deletions util/HelperUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ package util
func GetNFLFullTeamName(teamName, mascot string) string {
return teamName + " " + mascot
}

func GetWeekID(seasonID uint, week uint) uint {
// WeekID structure is the final two digits of the season year followed by the two digits representing the week.
// Season 1 == 2021
return (seasonID+2020-2000)*100 + week
}