logger update and makefile created

This commit is contained in:
Ravi Prasad
2025-11-12 21:11:16 -06:00
parent d34321c345
commit 21a68d7ef0
5 changed files with 25 additions and 11 deletions
+10
View File
@@ -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
+8 -4
View File
@@ -1,6 +1,6 @@
# NBA_Go
### Firsttime bootstrap
## Firsttime 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
+4 -4
View File
@@ -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"),
+2 -2
View File
@@ -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 📦")
+1 -1
View File
@@ -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)