shot chart service and models update

This commit is contained in:
Ravi Prasad
2025-05-13 22:10:42 -05:00
parent 5f67c07579
commit cdf5cf4cd2
14 changed files with 3117 additions and 115 deletions
+25 -19
View File
@@ -1,25 +1,31 @@
// NBA_Go/models/player_shot_chart.go
// models/player_shot_chart.go
package models
import "gorm.io/gorm"
type PlayerShotChart struct {
gorm.Model `swaggerignore:"true"`
ExternalID int `gorm:"not null;uniqueIndex:idx_shotchart_player_external" json:"id"`
PlayerID string `gorm:"not null;uniqueIndex:idx_shotchart_player_external" json:"playerId"`
PlayerName string `json:"playerName"`
Top int `json:"top"`
Left int `json:"left"`
Date string `json:"date"`
Quarter string `gorm:"column:qtr" json:"qtr"`
TimeRemaining string `gorm:"column:time_remaining" json:"timeRemaining"`
Result bool `json:"result"`
ShotType string `gorm:"column:shot_type" json:"shotType"`
DistanceFt int `gorm:"column:distance_ft" json:"distanceFt"`
Lead bool `json:"lead"`
TeamScore int `gorm:"column:team_score" json:"teamScore"`
OpponentTeamScore int `gorm:"column:opponent_team_score" json:"opponentTeamScore"`
Opponent string `json:"opponent"`
Team string `gorm:"not null" json:"team"`
Season int `gorm:"not null" json:"season"`
// Autoincrement primary key — works in SQLite and any other DB.
ID uint `gorm:"primaryKey" json:"id"`
// ────────── "identity" columns (the dedup key) ──────────
PlayerID string `gorm:"not null;uniqueIndex:idx_shot_identity,priority:1" json:"playerId"`
Season int `gorm:"not null;uniqueIndex:idx_shot_identity,priority:2" json:"season"`
Date string `gorm:"not null;uniqueIndex:idx_shot_identity,priority:3" json:"date"`
Quarter string `gorm:"column:qtr;uniqueIndex:idx_shot_identity,priority:4" json:"qtr"`
TimeRemaining string `gorm:"column:time_remaining;uniqueIndex:idx_shot_identity,priority:5" json:"timeRemaining"`
Top int `gorm:"uniqueIndex:idx_shot_identity,priority:6" json:"top"`
Left int `gorm:"uniqueIndex:idx_shot_identity,priority:7" json:"left"`
// ────────── the rest of the payload ──────────
PlayerName string `json:"playerName"`
Result bool `json:"result"`
ShotType string `gorm:"column:shot_type" json:"shotType"`
DistanceFt int `gorm:"column:distance_ft" json:"distanceFt"`
Lead bool `json:"lead"`
TeamScore int `gorm:"column:team_score" json:"teamScore"`
OpponentTeamScore int `gorm:"column:opponent_team_score" json:"opponentTeamScore"`
Opponent string `json:"opponent"`
Team string `gorm:"not null" json:"team"`
gorm.Model `swaggerignore:"true"` // keeps CreatedAt/UpdatedAt/DeletedAt
}