advanced models/controllers/service docs update

This commit is contained in:
Ravi Prasad
2025-05-12 19:40:51 -05:00
parent b6a3b59b3c
commit 8cad0e1980
10 changed files with 586 additions and 69 deletions
+3 -2
View File
@@ -11,7 +11,7 @@ import (
"gorm.io/gorm/clause"
)
func FetchAndStorePlayerAdvancedStats(db *gorm.DB, season int) error {
func FetchAndStorePlayerAdvancedStats(db *gorm.DB, season int, isPlayoff bool) error {
metrics.DBOperationsTotal.WithLabelValues("fetch", "player_advanced").Inc()
url := fmt.Sprintf("http://rest.nbaapi.com/api/PlayerDataAdvanced/query?season=%d&sortBy=Points&ascending=false&pageNumber=1&pageSize=1000", season)
@@ -28,9 +28,10 @@ func FetchAndStorePlayerAdvancedStats(db *gorm.DB, season int) error {
for _, stat := range stats {
// Ensure the season is included from the query param
stat.Season = season
stat.IsPlayoff = isPlayoff
err := db.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "player_id"}, {Name: "season"}, {Name: "team"}},
Columns: []clause.Column{{Name: "player_id"}, {Name: "season"}, {Name: "team"}, {Name: "is_playoff"}},
DoUpdates: clause.AssignmentColumns([]string{
"external_id", "player_name", "position", "age", "games",
"minutes_played", "per", "ts_percent", "three_par", "ftr",