mirror of
https://github.com/nprasad2077/NBA_Go.git
synced 2026-09-22 05:55:13 +00:00
logger update and makefile created
This commit is contained in:
@@ -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
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# NBA_Go
|
# NBA_Go
|
||||||
|
|
||||||
### First‑time bootstrap
|
## First‑time bootstrap
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 1. build + run
|
# 1. build + run
|
||||||
@@ -18,19 +18,23 @@ curl http://localhost:8080/api/playeradvancedstats \
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Swagger Initiate Docs
|
## Swagger Initiate Docs
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
swag init -g main.go -o docs
|
swag init -g main.go -o docs
|
||||||
```
|
```
|
||||||
|
|
||||||
### Test
|
## Test
|
||||||
|
|
||||||
```bash
|
```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"
|
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
|
```bash
|
||||||
docker-compose -f docker-compose.local.yml up --build -d
|
docker-compose -f docker-compose.local.yml up --build -d
|
||||||
|
|||||||
@@ -62,13 +62,13 @@ func importPlayerTotalsPlayoffsScrape(db *gorm.DB) {
|
|||||||
func importGameSchedules(db *gorm.DB) {
|
func importGameSchedules(db *gorm.DB) {
|
||||||
// An NBA season typically runs from October to June
|
// An NBA season typically runs from October to June
|
||||||
months := []string{
|
months := []string{
|
||||||
"septempber", "october", "november", "december", "january",
|
"september", "october", "november", "december", "january",
|
||||||
"february", "march", "april", "may", "june",
|
"february", "march", "april", "may", "june",
|
||||||
|
|
||||||
// "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)
|
log.Printf("--- Starting Game Schedule Import for Season: %d ---", season)
|
||||||
for _, month := range months {
|
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)
|
// 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)
|
// importBoxScores fetches and stores all box score data (line scores, player/team stats)
|
||||||
// for games within a recent date range.
|
// for games within a recent date range.
|
||||||
func importBoxScores(db *gorm.DB) {
|
func importBoxScores(db *gorm.DB) {
|
||||||
from := time.Date(2025, time.October, 1, 0, 0, 0, 0, time.UTC)
|
from := time.Date(2025, time.November, 1, 0, 0, 0, 0, time.UTC)
|
||||||
to := time.Date(2026, time.January, 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 ---",
|
dateRangeComment := fmt.Sprintf("--- Starting Box Score Data Import for games between %s and %s ---",
|
||||||
from.Format("January 2, 2006"),
|
from.Format("January 2, 2006"),
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ func main() {
|
|||||||
// importPlayerTotalsPlayoffsScrape(db)
|
// importPlayerTotalsPlayoffsScrape(db)
|
||||||
// log.Println("🎉 Player Playoffs (scraped) Import completed successfully")
|
// log.Println("🎉 Player Playoffs (scraped) Import completed successfully")
|
||||||
|
|
||||||
importGameSchedules(db)
|
// importGameSchedules(db)
|
||||||
log.Println("🎉 Game Imports completed successfully 🏀")
|
// log.Println("🎉 Game Imports completed successfully 🏀")
|
||||||
|
|
||||||
importBoxScores(db)
|
importBoxScores(db)
|
||||||
log.Println("🎉 Related Box Score Imports completed successfully 📦")
|
log.Println("🎉 Related Box Score Imports completed successfully 📦")
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ func scrapeAndParseWorker(id int, jobs <-chan models.Game, results chan<- Scrape
|
|||||||
}
|
}
|
||||||
|
|
||||||
for game := range jobs {
|
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
|
fullURL := boxScoreURLBase + game.BoxScoreURL
|
||||||
|
|
||||||
utils.SleepWithJitter(baseDelay)
|
utils.SleepWithJitter(baseDelay)
|
||||||
|
|||||||
Reference in New Issue
Block a user