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
32 changes: 17 additions & 15 deletions controller/GameDataController.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,22 +135,24 @@ func GetHomeAndAwayTeamData(w http.ResponseWriter, r *http.Request) {
}

func GetNFLHomeAndAwayTeamData(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")

vars := mux.Vars(r)
gameID := vars["gameID"]

gameChan := make(chan structs.NFLGame)
go func() {
g := managers.GetNFLGameByGameID(gameID)
gameChan <- g
}()
game := <-gameChan
close(gameChan)
g := managers.GetNFLGameByGameID(gameID)
if g.ID == 0 {
w.WriteHeader(http.StatusNotFound)
_ = json.NewEncoder(w).Encode(map[string]string{"error": "game not found"})
return
}

responseModel := models.NFLSimGameDataResponse{
GameID: int(game.ID),
WeekID: game.WeekID,
SeasonID: game.SeasonID,
GameID: int(g.ID),
WeekID: g.WeekID,
SeasonID: g.SeasonID,
}

var waitgroup sync.WaitGroup
waitgroup.Add(2)
var rosterGroup sync.WaitGroup
Expand All @@ -177,21 +179,21 @@ func GetNFLHomeAndAwayTeamData(w http.ResponseWriter, r *http.Request) {

go func() {
defer waitgroup.Done()
ht := managers.GetNFLTeamByTeamIDForSim(strconv.Itoa(game.HomeTeamID))
ht := managers.GetNFLTeamByTeamIDForSim(strconv.Itoa(g.HomeTeamID))
homeTeamChan <- ht
}()

go func() {
defer waitgroup.Done()
at := managers.GetNFLTeamByTeamIDForSim(strconv.Itoa(game.AwayTeamID))
at := managers.GetNFLTeamByTeamIDForSim(strconv.Itoa(g.AwayTeamID))
awayTeamChan <- at
}()

homeTeam := <-homeTeamChan
awayTeam := <-awayTeamChan
homeTeamID := strconv.Itoa(int(homeTeam.ID))
awayTeamID := strconv.Itoa(int(awayTeam.ID))
stadiumID := strconv.Itoa(int(game.StadiumID))
stadiumID := strconv.Itoa(int(g.StadiumID))

go func() {
defer rosterGroup.Done()
Expand Down Expand Up @@ -241,9 +243,9 @@ func GetNFLHomeAndAwayTeamData(w http.ResponseWriter, r *http.Request) {
awayTeamResponse.Map(awayTeam, awayDCResponse)
responseModel.AssignHomeTeam(homeTeamResponse, homeTeamRoster)
responseModel.AssignAwayTeam(awayTeamResponse, awayTeamRoster)
responseModel.AssignWeather(game.GameTemp, game.Cloud, game.Precip, game.WindCategory, game.WindSpeed)
responseModel.AssignWeather(g.GameTemp, g.Cloud, g.Precip, g.WindCategory, g.WindSpeed)
responseModel.AssignStadium(stadium)
responseModel.AssignPostSeasonStatus(game.IsConferenceChampionship || game.IsSuperBowl || game.IsPlayoffGame, game.IsNeutral)
responseModel.AssignPostSeasonStatus(g.IsConferenceChampionship || g.IsSuperBowl || g.IsPlayoffGame, g.IsNeutral)
json.NewEncoder(w).Encode(responseModel)
}

Expand Down
29 changes: 15 additions & 14 deletions data/defaultOffensiveSchemes.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@
"InvertedOptionRight": 13,
"TripleOptionLeft": 12,
"TripleOptionRight": 13,
"PassQuick": 10,
"PassShort": 15,
"PassQuick": 0,
"PassShort": 10,
"PassMedium": 15,
"PassLong": 15,
"PassDeep": 5,
"PassScreen": 5,
"PassPAShort": 25,
"PassPAMedium": 25,
"PassPALong": 20,
"PassPADeep": 5,
"LeftVsRight": 50,
Expand Down Expand Up @@ -153,7 +154,7 @@
"PassLong": 20,
"PassDeep": 5,
"PassScreen": 5,
"PassPAShort": 10,
"PassPAMedium": 10,
"PassPALong": 15,
"PassPADeep": 5,
"LeftVsRight": 50,
Expand Down Expand Up @@ -246,7 +247,7 @@
"PassLong": 5,
"PassDeep": 5,
"PassScreen": 10,
"PassPAShort": 10,
"PassPAMedium": 10,
"PassPALong": 5,
"PassPADeep": 5,
"LeftVsRight": 50,
Expand Down Expand Up @@ -339,7 +340,7 @@
"PassLong": 15,
"PassDeep": 5,
"PassScreen": 5,
"PassPAShort": 20,
"PassPAMedium": 20,
"PassPALong": 15,
"PassPADeep": 5,
"LeftVsRight": 50,
Expand Down Expand Up @@ -432,7 +433,7 @@
"PassLong": 20,
"PassDeep": 5,
"PassScreen": 15,
"PassPAShort": 10,
"PassPAMedium": 10,
"PassPALong": 5,
"PassPADeep": 5,
"LeftVsRight": 50,
Expand Down Expand Up @@ -525,7 +526,7 @@
"PassLong": 10,
"PassDeep": 5,
"PassScreen": 10,
"PassPAShort": 5,
"PassPAMedium": 5,
"PassPALong": 5,
"PassPADeep": 5,
"LeftVsRight": 50,
Expand Down Expand Up @@ -618,7 +619,7 @@
"PassLong": 15,
"PassDeep": 5,
"PassScreen": 10,
"PassPAShort": 20,
"PassPAMedium": 20,
"PassPALong": 5,
"PassPADeep": 5,
"LeftVsRight": 50,
Expand Down Expand Up @@ -711,7 +712,7 @@
"PassLong": 5,
"PassDeep": 5,
"PassScreen": 10,
"PassPAShort": 20,
"PassPAMedium": 20,
"PassPALong": 15,
"PassPADeep": 5,
"LeftVsRight": 50,
Expand Down Expand Up @@ -804,7 +805,7 @@
"PassLong": 15,
"PassDeep": 5,
"PassScreen": 5,
"PassPAShort": 25,
"PassPAMedium": 25,
"PassPALong": 20,
"PassPADeep": 5,
"LeftVsRight": 50,
Expand Down Expand Up @@ -897,7 +898,7 @@
"PassLong": 15,
"PassDeep": 5,
"PassScreen": 5,
"PassPAShort": 25,
"PassPAMedium": 25,
"PassPALong": 20,
"PassPADeep": 5,
"LeftVsRight": 50,
Expand Down Expand Up @@ -990,7 +991,7 @@
"PassLong": 15,
"PassDeep": 5,
"PassScreen": 10,
"PassPAShort": 20,
"PassPAMedium": 20,
"PassPALong": 5,
"PassPADeep": 5,
"LeftVsRight": 50,
Expand Down Expand Up @@ -1083,7 +1084,7 @@
"PassLong": 5,
"PassDeep": 5,
"PassScreen": 10,
"PassPAShort": 30,
"PassPAMedium": 30,
"PassPALong": 25,
"PassPADeep": 5,
"LeftVsRight": 50,
Expand Down
48 changes: 37 additions & 11 deletions managers/BootstrapManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ type BootstrapDataLanding struct {
}

type BootstrapDataTeamRoster struct {
ContractMap map[uint]structs.NFLContract
ExtensionMap map[uint]structs.NFLExtensionOffer
CollegePromises []structs.CollegePromise
ContractMap map[uint]structs.NFLContract
ExtensionMap map[uint]structs.NFLExtensionOffer
CollegePromises []structs.CollegePromise
TradeProposals structs.NFLTeamProposals
TradePreferences map[uint]structs.NFLTradePreferences
NFLDraftPicks []structs.NFLDraftPick
}

type BootstrapDataRecruiting struct {
Expand Down Expand Up @@ -305,21 +308,25 @@ func GetLandingBootstrap(collegeID, proID string) BootstrapDataLanding {
func GetTeamRosterBootstrap(collegeID, nflID string) BootstrapDataTeamRoster {
var wg sync.WaitGroup
var (
contractMap map[uint]structs.NFLContract
extensionMap map[uint]structs.NFLExtensionOffer
collegePromises []structs.CollegePromise
contractMap map[uint]structs.NFLContract
extensionMap map[uint]structs.NFLExtensionOffer
collegePromises []structs.CollegePromise
tradeProposals structs.NFLTeamProposals
tradePreferencesMap map[uint]structs.NFLTradePreferences
draftPicks []structs.NFLDraftPick
)

if len(collegeID) > 0 && collegeID != "0" {
wg.Add(1)
go func() {
defer wg.Done()
promises := GetCollegePromisesByTeamID(collegeID)
collegePromises = promises
}()
}

if len(nflID) > 0 && nflID != "0" {
wg.Add(2)
wg.Add(5)
go func() {
defer wg.Done()
contractMap = GetContractMap()
Expand All @@ -329,11 +336,30 @@ func GetTeamRosterBootstrap(collegeID, nflID string) BootstrapDataTeamRoster {
defer wg.Done()
extensionMap = GetExtensionMap()
}()

go func() {
defer wg.Done()
tradeProposals = GetTradeProposalsByNFLID(nflID)
}()

go func() {
defer wg.Done()
tradePreferencesMap = GetTradePreferencesMap()
}()
go func() {
defer wg.Done()
draftPicks = GetAllRelevantNFLDraftPicks()
}()
}

wg.Wait()
return BootstrapDataTeamRoster{
ContractMap: contractMap,
ExtensionMap: extensionMap,
CollegePromises: collegePromises,
ContractMap: contractMap,
ExtensionMap: extensionMap,
CollegePromises: collegePromises,
TradeProposals: tradeProposals,
TradePreferences: tradePreferencesMap,
NFLDraftPicks: draftPicks,
}
}

Expand Down Expand Up @@ -425,7 +451,7 @@ func GetCollegePollsBootstrap(username, collegeID, seasonID string) BootstrapDat
wg.Add(2)
go func() {
defer wg.Done()
officialPolls = GetOfficialPollBySeasonID(seasonID)
officialPolls = GetAllOfficialPolls()
}()
go func() {
defer wg.Done()
Expand Down
Loading