models migrated and data insert success with dbeaver

This commit is contained in:
Ravi Prasad
2025-07-04 03:12:59 -05:00
parent cbbb1aef44
commit a16af088af
4 changed files with 17 additions and 6 deletions
Vendored
BIN
View File
Binary file not shown.
+12 -1
View File
@@ -40,8 +40,19 @@ func InitDB(shouldMigrate bool) *gorm.DB {
if err := db.AutoMigrate(&models.APIKey{}); err != nil {
log.Fatalf("migrate APIKey: %v", err)
}
// Game Models
if err := db.AutoMigrate(
&models.Game{},
&models.LineScore{},
&models.PlayerGameBasicStat{},
&models.PlayerGameAdvStat{},
&models.TeamGameBasicStat{},
&models.TeamGameAdvStat{},
); err != nil {
log.Fatalf("migrate game models: %v", err)
}
metrics.DBOperationsTotal.WithLabelValues("migrate", "database").Inc()
}
return db
}
}
+1 -1
View File
@@ -25,7 +25,7 @@ services:
db-init:
build: .
env_file: .env
command: ["/nba_go"]
command: ["/nba_go", "import-data"]
depends_on:
postgres:
condition: service_healthy
+4 -4
View File
@@ -11,7 +11,7 @@ import (
// importPlayerAdvanced fetches and stores advanced stats for seasons 20172025
func importPlayerAdvanced(db *gorm.DB) {
for season := 2024; season <= 2025; season++ {
for season := 2022; season <= 2025; season++ {
if err := services.FetchAndStorePlayerAdvancedScrapedStats(db, season, false); err != nil {
log.Printf("advanced import failed for %d: %v", season, err)
}
@@ -23,7 +23,7 @@ func importPlayerAdvanced(db *gorm.DB) {
// importPlayerAdvancedPlayoffs fetches and stores advanced stats for playoffs seasons 20232025
func importPlayerAdvancedPlayoffs(db *gorm.DB) {
for season := 2024; season <= 2025; season++ {
for season := 2022; season <= 2025; season++ {
if err := services.FetchAndStorePlayerAdvancedScrapedStats(db, season, true); err != nil {
log.Printf("advanced import failed for %d: %v", season, err)
}
@@ -35,7 +35,7 @@ func importPlayerAdvancedPlayoffs(db *gorm.DB) {
// importPlayerTotalsScrape fetches & stores scraped regular-season total stats
func importPlayerTotalsScrape(db *gorm.DB) {
for season := 2024; season <= 2025; season++ {
for season := 2022; season <= 2025; season++ {
if err := services.FetchAndStorePlayerTotalScrapedStats(db, season, false); err != nil {
log.Printf("scraped totals import failed for %d: %v", season, err)
}
@@ -47,7 +47,7 @@ func importPlayerTotalsScrape(db *gorm.DB) {
// importPlayerPlayoffsScrape fetches & stores scraped playoff total stats
func importPlayerTotalsPlayoffsScrape(db *gorm.DB) {
for season := 2024; season <= 2025; season++ {
for season := 2022; season <= 2025; season++ {
if err := services.FetchAndStorePlayerTotalScrapedStats(db, season, true); err != nil {
log.Printf("scraped playoffs import failed for %d: %v", season, err)
}