diff --git a/.gitignore b/.gitignore index bdc8b3e..660eeeb 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ coverage tmp build *.log +db.sql \ No newline at end of file diff --git a/db/migrations/000001_fortune.up.sql b/db/migrations/000001_fortune.up.sql index 4fb809e..7f5896f 100644 --- a/db/migrations/000001_fortune.up.sql +++ b/db/migrations/000001_fortune.up.sql @@ -231,7 +231,8 @@ CREATE TABLE odds ( source TEXT DEFAULT 'b365api', is_active BOOLEAN DEFAULT true, UNIQUE (market_id, name, handicap), - UNIQUE (event_id, market_id, name, handicap) + UNIQUE (event_id, market_id, name, handicap), + UNIQUE (event_id, market_id) ); ALTER TABLE refresh_tokens ADD CONSTRAINT fk_refresh_tokens_users FOREIGN KEY (user_id) REFERENCES users(id); diff --git a/internal/web_server/cron.go b/internal/web_server/cron.go index 5aaa06d..7cf442f 100644 --- a/internal/web_server/cron.go +++ b/internal/web_server/cron.go @@ -20,7 +20,8 @@ func StartDataFetchingCrons(eventService eventsvc.Service, oddsService oddssvc.S }{ { - spec: "*/30 * * * * *", // Every 30 seconds + + spec: "0 0 * * * *", // Every hour task: func() { if err := eventService.FetchUpcomingEvents(context.Background()); err != nil { log.Printf("FetchUpcomingEvents error: %v", err) @@ -38,7 +39,7 @@ func StartDataFetchingCrons(eventService eventsvc.Service, oddsService oddssvc.S // }, { - spec: "*/5 * * * * *", // Every 5 seconds + spec: "0 */15 * * * *", // Every 15 minutes task: func() { if err := oddsService.FetchNonLiveOdds(context.Background()); err != nil { log.Printf("FetchNonLiveOdds error: %v", err)