diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d9951f1 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +# Tells 'make' these are command names, not files +.PHONY: up down + +# Command to run: make up +up: + docker-compose -f docker-compose.local.yml up --build -d + +# Command to run: make down +down: + docker-compose down \ No newline at end of file diff --git a/README.md b/README.md index 2652ff9..61854ee 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # NBA_Go -### Firstโ€‘time bootstrap +## Firstโ€‘time bootstrap ```bash # 1. build + run @@ -18,19 +18,23 @@ curl http://localhost:8080/api/playeradvancedstats \ ``` -### Swagger Initiate Docs +## Swagger Initiate Docs ```bash swag init -g main.go -o docs ``` -### Test +## Test ```bash go run loadtest.go -n 100 -c 10 -url "http://127.0.0.1:8080/api/playeradvancedstats?page=1&pageSize=20" -log results.log -key "xxx" ``` -### Local Environment +## Local Environment + +```bash +docker compose down +``` ```bash docker-compose -f docker-compose.local.yml up --build -d diff --git a/import.go b/import.go index df515a4..a252895 100644 --- a/import.go +++ b/import.go @@ -62,13 +62,13 @@ func importPlayerTotalsPlayoffsScrape(db *gorm.DB) { func importGameSchedules(db *gorm.DB) { // An NBA season typically runs from October to June months := []string{ - "septempber", "october", "november", "december", "january", + "september", "october", "november", "december", "january", "february", "march", "april", "may", "june", // "february", "march", "april", "may", "june", } - for season := 2024; season <= 2026; season++ { + for season := 2015; season <= 2015; season++ { log.Printf("--- Starting Game Schedule Import for Season: %d ---", season) for _, month := range months { // The service will print a warning and skip if a month has no data (e.g. May/June for a season not yet finished) @@ -88,8 +88,8 @@ func importGameSchedules(db *gorm.DB) { // importBoxScores fetches and stores all box score data (line scores, player/team stats) // for games within a recent date range. func importBoxScores(db *gorm.DB) { - from := time.Date(2025, time.October, 1, 0, 0, 0, 0, time.UTC) - to := time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC) + from := time.Date(2025, time.November, 1, 0, 0, 0, 0, time.UTC) + to := time.Date(2025, time.December, 1, 0, 0, 0, 0, time.UTC) dateRangeComment := fmt.Sprintf("--- Starting Box Score Data Import for games between %s and %s ---", from.Format("January 2, 2006"), diff --git a/main.go b/main.go index 2da8e04..535b39b 100644 --- a/main.go +++ b/main.go @@ -62,8 +62,8 @@ func main() { // importPlayerTotalsPlayoffsScrape(db) // log.Println("๐ŸŽ‰ Player Playoffs (scraped) Import completed successfully") - importGameSchedules(db) - log.Println("๐ŸŽ‰ Game Imports completed successfully ๐Ÿ€") + // importGameSchedules(db) + // log.Println("๐ŸŽ‰ Game Imports completed successfully ๐Ÿ€") importBoxScores(db) log.Println("๐ŸŽ‰ Related Box Score Imports completed successfully ๐Ÿ“ฆ") diff --git a/services/box_score_scrape_service.go b/services/box_score_scrape_service.go index a4111cc..2a453fd 100644 --- a/services/box_score_scrape_service.go +++ b/services/box_score_scrape_service.go @@ -132,7 +132,7 @@ func scrapeAndParseWorker(id int, jobs <-chan models.Game, results chan<- Scrape } for game := range jobs { - log.Printf("Worker %d: Processing game %s", id, game.GameID) + log.Printf("๐Ÿ Worker %d: Processing game %s", id, game.GameID) fullURL := boxScoreURLBase + game.BoxScoreURL utils.SleepWithJitter(baseDelay)