From d416a40caefa3268c7a97950d2ed6e4ec6792881 Mon Sep 17 00:00:00 2001 From: OneTap Technologies Date: Mon, 14 Apr 2025 16:52:42 +0300 Subject: [PATCH] fix odd --- db/query/odds.sql | 25 +++++++++++++++---------- gen/db/odds.sql.go | 22 ++++++++++++---------- internal/web_server/cron.go | 4 ++-- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/db/query/odds.sql b/db/query/odds.sql index 912b1f9..84e6382 100644 --- a/db/query/odds.sql +++ b/db/query/odds.sql @@ -16,19 +16,24 @@ INSERT INTO odds ( source, fetched_at ) VALUES ( - $1, $2, $3, $4, $5, $6, $7, + $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15 ) -ON CONFLICT (market_id, name, handicap) DO UPDATE SET - odds_value = EXCLUDED.odds_value, - raw_odds = EXCLUDED.raw_odds, - market_type = EXCLUDED.market_type, - market_name = EXCLUDED.market_name, +ON CONFLICT (event_id, market_id) DO UPDATE SET + odds_value = EXCLUDED.odds_value, + raw_odds = EXCLUDED.raw_odds, + market_type = EXCLUDED.market_type, + market_name = EXCLUDED.market_name, market_category = EXCLUDED.market_category, - fetched_at = EXCLUDED.fetched_at, - is_active = EXCLUDED.is_active, - source = EXCLUDED.source, - fi = EXCLUDED.fi; + name = EXCLUDED.name, + handicap = EXCLUDED.handicap, + fetched_at = EXCLUDED.fetched_at, + is_active = EXCLUDED.is_active, + source = EXCLUDED.source, + fi = EXCLUDED.fi; + + + -- name: GetPrematchOdds :many SELECT diff --git a/gen/db/odds.sql.go b/gen/db/odds.sql.go index 66c4078..57865e6 100644 --- a/gen/db/odds.sql.go +++ b/gen/db/odds.sql.go @@ -292,19 +292,21 @@ INSERT INTO odds ( source, fetched_at ) VALUES ( - $1, $2, $3, $4, $5, $6, $7, + $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15 ) -ON CONFLICT (market_id, name, handicap) DO UPDATE SET - odds_value = EXCLUDED.odds_value, - raw_odds = EXCLUDED.raw_odds, - market_type = EXCLUDED.market_type, - market_name = EXCLUDED.market_name, +ON CONFLICT (event_id, market_id) DO UPDATE SET + odds_value = EXCLUDED.odds_value, + raw_odds = EXCLUDED.raw_odds, + market_type = EXCLUDED.market_type, + market_name = EXCLUDED.market_name, market_category = EXCLUDED.market_category, - fetched_at = EXCLUDED.fetched_at, - is_active = EXCLUDED.is_active, - source = EXCLUDED.source, - fi = EXCLUDED.fi + name = EXCLUDED.name, + handicap = EXCLUDED.handicap, + fetched_at = EXCLUDED.fetched_at, + is_active = EXCLUDED.is_active, + source = EXCLUDED.source, + fi = EXCLUDED.fi ` type InsertNonLiveOddParams struct { diff --git a/internal/web_server/cron.go b/internal/web_server/cron.go index ddf9677..2ee4e69 100644 --- a/internal/web_server/cron.go +++ b/internal/web_server/cron.go @@ -37,8 +37,8 @@ func StartDataFetchingCrons(eventService eventsvc.Service, oddsService oddssvc.S // }, - // { - // spec: "*/30 * * * * *", // Every 30 seconds + // { + // spec: "*/5 * * * * *", // Every 5 seconds // task: func() { // if err := oddsService.FetchNonLiveOdds(context.Background()); err != nil { // log.Printf("FetchNonLiveOdds error: %v", err)