This commit is contained in:
Ravi Prasad
2025-06-03 21:29:16 -05:00
parent a3225b1803
commit 24ec6675c9
7 changed files with 108 additions and 107 deletions
+3 -3
View File
@@ -1,11 +1,11 @@
package config
import (
"log"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"github.com/nprasad2077/NBA_Go/models"
"github.com/nprasad2077/NBA_Go/utils/metrics"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"log"
)
func InitDB(shouldMigrate bool) *gorm.DB {
+2 -2
View File
@@ -47,14 +47,14 @@ func ScrapePlayerAdvancedStats(db *gorm.DB) fiber.Handler {
return func(c *fiber.Ctx) error {
season := c.QueryInt("season", 0)
if season == 0 {
return c.Status(400).JSON(fiber.Map{"error":"season is required"})
return c.Status(400).JSON(fiber.Map{"error": "season is required"})
}
isPlayoff := c.QueryBool("isPlayoff", false)
if err := services.FetchAndStorePlayerAdvancedScrapedStats(db, season, isPlayoff); err != nil {
return c.Status(500).JSON(fiber.Map{"error": err.Error()})
}
return c.JSON(fiber.Map{"message":"scrape+store complete"})
return c.JSON(fiber.Map{"message": "scrape+store complete"})
}
}
@@ -32,7 +32,9 @@ import (
// ScrapePlayerShotChart godoc
// @Summary Scrape a player's shot-chart from BR website
// @Description Scrapes seasons [startSeason…endSeason] for the given playerId
//
// (playerName is auto-detected).
//
// @Tags PlayerShotChart
// @Accept json
// @Produce json
+3 -4
View File
@@ -14,9 +14,9 @@ package controllers
import (
"github.com/gofiber/fiber/v2"
"github.com/nprasad2077/NBA_Go/models"
"github.com/nprasad2077/NBA_Go/services"
"gorm.io/gorm"
"github.com/nprasad2077/NBA_Go/models"
)
// func FetchPlayerTotalStats(db *gorm.DB) fiber.Handler {
@@ -45,18 +45,17 @@ func ScrapePlayerTotalStats(db *gorm.DB) fiber.Handler {
return func(c *fiber.Ctx) error {
season := c.QueryInt("season", 0)
if season == 0 {
return c.Status(400).JSON(fiber.Map{"error":"season is required"})
return c.Status(400).JSON(fiber.Map{"error": "season is required"})
}
isPlayoff := c.QueryBool("isPlayoff", false)
if err := services.FetchAndStorePlayerTotalScrapedStats(db, season, isPlayoff); err != nil {
return c.Status(500).JSON(fiber.Map{"error": err.Error()})
}
return c.JSON(fiber.Map{"message":"scrapestore complete"})
return c.JSON(fiber.Map{"message": "scrapestore complete"})
}
}
// GetPlayerTotalStats godoc
// @Security ApiKeyAuth
// @Summary Get player total stats