totals data service update added to import and main.go

This commit is contained in:
Ravi Prasad
2025-05-13 17:51:51 -05:00
parent e63862c943
commit 5f67c07579
3 changed files with 50 additions and 237 deletions
+38 -18
View File
@@ -20,7 +20,7 @@ func importPlayerAdvanced(db *gorm.DB) {
// importPlayerAdvancedPlayoffs fetches and stores advanced stats for playoffs seasons 20232025
func importPlayerAdvancedPlayoffs (db *gorm.DB) {
func importPlayerAdvancedPlayoffs(db *gorm.DB) {
for season := 2023; season <= 2024; season++ {
if err := services.FetchAndStorePlayerAdvancedPlayoffsStats(db, season, true); err != nil {
log.Printf("advanced import failed for %d: %v", season, err)
@@ -30,24 +30,24 @@ func importPlayerAdvancedPlayoffs (db *gorm.DB) {
}
// importPlayerTotals fetches and stores regular-season total stats for seasons 20232025
func importPlayerTotals(db *gorm.DB) {
for season := 2023; season <= 2025; season++ {
if err := services.FetchAndStorePlayerTotalStats(db, season, false); err != nil {
log.Printf("totals import failed for %d: %v", season, err)
}
time.Sleep(1000 * time.Millisecond)
}
}
// func importPlayerTotals(db *gorm.DB) {
// for season := 2023; season <= 2025; season++ {
// if err := services.FetchAndStorePlayerTotalStats(db, season, false); err != nil {
// log.Printf("totals import failed for %d: %v", season, err)
// }
// time.Sleep(1000 * time.Millisecond)
// }
// }
// importPlayerPlayoffs fetches and stores playoff total stats for seasons 20232024
func importPlayerPlayoffs(db *gorm.DB) {
for season := 2023; season <= 2024; season++ {
if err := services.FetchAndStorePlayerTotalPlayoffsStats(db, season, true); err != nil {
log.Printf("playoffs import failed for %d: %v", season, err)
}
time.Sleep(1500 * time.Millisecond)
}
}
// // importPlayerPlayoffs fetches and stores playoff total stats for seasons 20232024
// func importPlayerPlayoffs(db *gorm.DB) {
// for season := 2023; season <= 2024; season++ {
// if err := services.FetchAndStorePlayerTotalPlayoffsStats(db, season, true); err != nil {
// log.Printf("playoffs import failed for %d: %v", season, err)
// }
// time.Sleep(1500 * time.Millisecond)
// }
// }
// importPlayerShotChart fetches shot-charts for every known player
func importPlayerShotChart(db *gorm.DB) {
@@ -58,3 +58,23 @@ func importPlayerShotChart(db *gorm.DB) {
}
// you can add more IDs here or just rely on the API endpoint after
}
// importPlayerTotalsScrape fetches & stores scraped regular-season total stats
func importPlayerTotalsScrape(db *gorm.DB) {
for season := 2023; season <= 2025; season++ {
if err := services.FetchAndStorePlayerTotalScrapedStats(db, season, false); err != nil {
log.Printf("scraped totals import failed for %d: %v", season, err)
}
time.Sleep(1100 * time.Millisecond)
}
}
// importPlayerPlayoffsScrape fetches & stores scraped playoff total stats
func importPlayerPlayoffsScrape(db *gorm.DB) {
for season := 2023; season <= 2024; season++ {
if err := services.FetchAndStorePlayerTotalScrapedStats(db, season, true); err != nil {
log.Printf("scraped playoffs import failed for %d: %v", season, err)
}
time.Sleep(1500 * time.Millisecond)
}
}