Skip to content

Commit

Permalink
fixing stats page call for historical data by game type
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebRose committed Nov 5, 2024
1 parent b355aad commit 42def84
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions managers/PlayerManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,13 @@ func GetAllCollegePlayersWithStatsBySeasonID(cMap map[int]int, cNMap map[int]str
// var distinctCollegeStats []structs.CollegePlayerStats
var distinctCollegeStats []structs.CollegePlayerSeasonStats

db.Distinct("college_player_id").Where("snaps > 0 AND season_id = ?", seasonID).Find(&distinctCollegeStats)
db.Distinct("college_player_id").Where("snaps > 0 AND season_id = ? AND game_type = ?", seasonID, gameType).Find(&distinctCollegeStats)

distinctCollegePlayerIDs := GetCollegePlayerIDsBySeasonStats(distinctCollegeStats)

if viewType == "SEASON" {
db.Preload("SeasonStats", func(db *gorm.DB) *gorm.DB {
return db.Where("season_id = ?", seasonID)
return db.Where("season_id = ? AND game_type = ?", seasonID, gameType)
}).Where("id in ?", distinctCollegePlayerIDs).Find(&collegePlayers)
} else {
db.Preload("Stats", func(db *gorm.DB) *gorm.DB {
Expand Down Expand Up @@ -383,7 +383,7 @@ func GetAllCollegePlayersWithStatsBySeasonID(cMap map[int]int, cNMap map[int]str

if viewType == "SEASON" {
db.Preload("SeasonStats", func(db *gorm.DB) *gorm.DB {
return db.Where("season_id = ?", seasonID)
return db.Where("season_id = ? AND game_type = ?", seasonID, gameType)
}).Where("id in ?", distinctCollegePlayerIDs).Find(&historicCollegePlayers)
} else {
db.Preload("Stats", func(db *gorm.DB) *gorm.DB {
Expand Down Expand Up @@ -439,7 +439,7 @@ func GetAllNFLPlayersWithStatsBySeasonID(cMap, dMap map[int]int, cNMap, dNMap ma

if viewType == "SEASON" {
db.Preload("SeasonStats", func(db *gorm.DB) *gorm.DB {
return db.Where("season_id = ?", seasonID)
return db.Where("season_id = ? AND game_type = ?", seasonID, gameType)
}).Where("id in ?", distinctCollegePlayerIDs).Find(&nflPlayers)
} else {
db.Preload("Stats", func(db *gorm.DB) *gorm.DB {
Expand Down Expand Up @@ -483,7 +483,7 @@ func GetAllNFLPlayersWithStatsBySeasonID(cMap, dMap map[int]int, cNMap, dNMap ma

if viewType == "SEASON" {
db.Preload("SeasonStats", func(db *gorm.DB) *gorm.DB {
return db.Where("season_id = ?", seasonID)
return db.Where("season_id = ? AND game_type = ?", seasonID, gameType)
}).Where("id in ?", distinctCollegePlayerIDs).Find(&historicNFLPlayers)
} else {
db.Preload("Stats", func(db *gorm.DB) *gorm.DB {
Expand Down

0 comments on commit 42def84

Please sign in to comment.