feat: Add number_of_outcomes to odds market queries and models
- Updated SQL queries to include number_of_outcomes in GetAllOdds, GetOddByID, GetOddsByEventID, and GetOddsByMarketID. - Modified data structures in domain and repository layers to accommodate number_of_outcomes. - Enhanced event models to track total odd outcomes. - Introduced new SQL scripts for development data seeding.
This commit is contained in:
parent
b5932df206
commit
a9025ca844
221
db/dev_data/betfidel_data.sql
Normal file
221
db/dev_data/betfidel_data.sql
Normal file
|
|
@ -0,0 +1,221 @@
|
||||||
|
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
||||||
|
DO $$
|
||||||
|
DECLARE _admin_id bigint;
|
||||||
|
_manager_id bigint;
|
||||||
|
_company_wallet_id bigint;
|
||||||
|
_company_id bigint;
|
||||||
|
_branch_id bigint;
|
||||||
|
_branch_wallet_id bigint;
|
||||||
|
_cashier_id bigint;
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO users (
|
||||||
|
first_name,
|
||||||
|
last_name,
|
||||||
|
email,
|
||||||
|
phone_number,
|
||||||
|
password,
|
||||||
|
role,
|
||||||
|
email_verified,
|
||||||
|
phone_verified,
|
||||||
|
created_at,
|
||||||
|
updated_at,
|
||||||
|
suspended
|
||||||
|
)
|
||||||
|
VALUES (
|
||||||
|
'Admin',
|
||||||
|
'BetFidel',
|
||||||
|
'admin.betfidel@gmail.com',
|
||||||
|
NULL,
|
||||||
|
crypt('password@123', gen_salt('bf'))::bytea,
|
||||||
|
'admin',
|
||||||
|
TRUE,
|
||||||
|
FALSE,
|
||||||
|
CURRENT_TIMESTAMP,
|
||||||
|
CURRENT_TIMESTAMP,
|
||||||
|
FALSE
|
||||||
|
) ON CONFLICT (email) DO
|
||||||
|
UPDATE
|
||||||
|
SET updated_at = EXCLUDED.updated_at
|
||||||
|
RETURNING id INTO STRICT _admin_id;
|
||||||
|
INSERT INTO users (
|
||||||
|
first_name,
|
||||||
|
last_name,
|
||||||
|
email,
|
||||||
|
phone_number,
|
||||||
|
password,
|
||||||
|
role,
|
||||||
|
email_verified,
|
||||||
|
phone_verified,
|
||||||
|
created_at,
|
||||||
|
updated_at,
|
||||||
|
suspended,
|
||||||
|
company_id
|
||||||
|
)
|
||||||
|
VALUES (
|
||||||
|
'Manager',
|
||||||
|
'BetFidel',
|
||||||
|
'manager.betfidel@gmail.com',
|
||||||
|
NULL,
|
||||||
|
crypt('password@123', gen_salt('bf'))::bytea,
|
||||||
|
'branch_manager',
|
||||||
|
TRUE,
|
||||||
|
FALSE,
|
||||||
|
CURRENT_TIMESTAMP,
|
||||||
|
CURRENT_TIMESTAMP,
|
||||||
|
FALSE,
|
||||||
|
_company_id
|
||||||
|
) ON CONFLICT (email) DO
|
||||||
|
UPDATE
|
||||||
|
SET updated_at = EXCLUDED.updated_at
|
||||||
|
RETURNING id INTO STRICT _manager_id;
|
||||||
|
INSERT INTO wallets (
|
||||||
|
balance,
|
||||||
|
is_withdraw,
|
||||||
|
is_bettable,
|
||||||
|
is_transferable,
|
||||||
|
user_id,
|
||||||
|
type,
|
||||||
|
currency,
|
||||||
|
is_active,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
)
|
||||||
|
VALUES (
|
||||||
|
10000,
|
||||||
|
TRUE,
|
||||||
|
TRUE,
|
||||||
|
TRUE,
|
||||||
|
_admin_id,
|
||||||
|
'company_wallet',
|
||||||
|
'ETB',
|
||||||
|
TRUE,
|
||||||
|
CURRENT_TIMESTAMP,
|
||||||
|
CURRENT_TIMESTAMP
|
||||||
|
) ON CONFLICT (user_id, type) DO
|
||||||
|
UPDATE
|
||||||
|
SET updated_at = EXCLUDED.updated_at
|
||||||
|
RETURNING id INTO STRICT _company_wallet_id;
|
||||||
|
INSERT INTO companies (
|
||||||
|
name,
|
||||||
|
slug,
|
||||||
|
admin_id,
|
||||||
|
wallet_id,
|
||||||
|
deducted_percentage,
|
||||||
|
is_active,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
)
|
||||||
|
VALUES (
|
||||||
|
'FidelBet',
|
||||||
|
'betfidel',
|
||||||
|
_admin_id,
|
||||||
|
_company_wallet_id,
|
||||||
|
0.15,
|
||||||
|
TRUE,
|
||||||
|
CURRENT_TIMESTAMP,
|
||||||
|
CURRENT_TIMESTAMP
|
||||||
|
) ON CONFLICT (slug) DO
|
||||||
|
UPDATE
|
||||||
|
SET updated_at = EXCLUDED.updated_at
|
||||||
|
RETURNING id INTO STRICT _company_id;
|
||||||
|
UPDATE users
|
||||||
|
SET company_id = _company_id
|
||||||
|
WHERE id = _admin_id;
|
||||||
|
INSERT INTO wallets (
|
||||||
|
balance,
|
||||||
|
is_withdraw,
|
||||||
|
is_bettable,
|
||||||
|
is_transferable,
|
||||||
|
user_id,
|
||||||
|
type,
|
||||||
|
currency,
|
||||||
|
is_active,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
)
|
||||||
|
VALUES (
|
||||||
|
10000,
|
||||||
|
TRUE,
|
||||||
|
TRUE,
|
||||||
|
TRUE,
|
||||||
|
_admin_id,
|
||||||
|
'branch_wallet',
|
||||||
|
'ETB',
|
||||||
|
TRUE,
|
||||||
|
CURRENT_TIMESTAMP,
|
||||||
|
CURRENT_TIMESTAMP
|
||||||
|
) ON CONFLICT (user_id, type) DO
|
||||||
|
UPDATE
|
||||||
|
SET updated_at = EXCLUDED.updated_at
|
||||||
|
RETURNING id INTO STRICT _branch_wallet_id;
|
||||||
|
INSERT INTO branches (
|
||||||
|
name,
|
||||||
|
location,
|
||||||
|
wallet_id,
|
||||||
|
branch_manager_id,
|
||||||
|
company_id,
|
||||||
|
is_self_owned,
|
||||||
|
profit_percent,
|
||||||
|
is_active,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
)
|
||||||
|
VALUES (
|
||||||
|
'Test Branch',
|
||||||
|
'addis_ababa',
|
||||||
|
_branch_wallet_id,
|
||||||
|
_manager_id,
|
||||||
|
_company_id,
|
||||||
|
TRUE,
|
||||||
|
0.10,
|
||||||
|
TRUE,
|
||||||
|
CURRENT_TIMESTAMP,
|
||||||
|
CURRENT_TIMESTAMP
|
||||||
|
) ON CONFLICT (wallet_id) DO
|
||||||
|
UPDATE
|
||||||
|
SET updated_at = EXCLUDED.updated_at
|
||||||
|
RETURNING id INTO STRICT _branch_id;
|
||||||
|
INSERT INTO users (
|
||||||
|
first_name,
|
||||||
|
last_name,
|
||||||
|
email,
|
||||||
|
phone_number,
|
||||||
|
password,
|
||||||
|
role,
|
||||||
|
email_verified,
|
||||||
|
phone_verified,
|
||||||
|
created_at,
|
||||||
|
updated_at,
|
||||||
|
suspended,
|
||||||
|
company_id
|
||||||
|
)
|
||||||
|
VALUES (
|
||||||
|
'Cashier',
|
||||||
|
'BetFidel',
|
||||||
|
'cashier.betfidel@gmail.com',
|
||||||
|
NULL,
|
||||||
|
crypt('password@123', gen_salt('bf'))::bytea,
|
||||||
|
'cashier',
|
||||||
|
TRUE,
|
||||||
|
FALSE,
|
||||||
|
CURRENT_TIMESTAMP,
|
||||||
|
CURRENT_TIMESTAMP,
|
||||||
|
FALSE,
|
||||||
|
_company_id
|
||||||
|
) ON CONFLICT (email) DO
|
||||||
|
UPDATE
|
||||||
|
SET updated_at = EXCLUDED.updated_at
|
||||||
|
RETURNING id INTO STRICT _cashier_id;
|
||||||
|
INSERT INTO branch_cashiers (user_id, branch_id)
|
||||||
|
VALUES (_cashier_id, _branch_id);
|
||||||
|
RAISE NOTICE 'BETFIDEL_DEV_DATA (Admin ID: %, Company Wallet ID: %, Company ID: %)',
|
||||||
|
_admin_id,
|
||||||
|
_company_wallet_id,
|
||||||
|
_company_id;
|
||||||
|
RAISE NOTICE 'BETFIDEL_DEV_DATA (Branch ID: %, Branch Wallet ID: %, Manager ID: %)',
|
||||||
|
_branch_id,
|
||||||
|
_branch_wallet_id,
|
||||||
|
_manager_id;
|
||||||
|
RAISE NOTICE 'BETFIDEL_DEV_DATA (Cashier ID: %)',
|
||||||
|
_cashier_id;
|
||||||
|
END $$;
|
||||||
|
|
@ -354,6 +354,7 @@ CREATE TABLE odds_market (
|
||||||
market_category TEXT NOT NULL,
|
market_category TEXT NOT NULL,
|
||||||
market_id BIGINT NOT NULL,
|
market_id BIGINT NOT NULL,
|
||||||
raw_odds JSONB NOT NULL,
|
raw_odds JSONB NOT NULL,
|
||||||
|
number_of_outcomes BIGINT NOT NULL,
|
||||||
default_is_active BOOLEAN NOT NULL DEFAULT true,
|
default_is_active BOOLEAN NOT NULL DEFAULT true,
|
||||||
fetched_at TIMESTAMP DEFAULT now (),
|
fetched_at TIMESTAMP DEFAULT now (),
|
||||||
expires_at TIMESTAMP NOT NULL,
|
expires_at TIMESTAMP NOT NULL,
|
||||||
|
|
@ -693,15 +694,29 @@ SELECT e.*,
|
||||||
e.default_winning_upper_limit
|
e.default_winning_upper_limit
|
||||||
) AS winning_upper_limit,
|
) AS winning_upper_limit,
|
||||||
ces.updated_at as company_updated_at,
|
ces.updated_at as company_updated_at,
|
||||||
l.country_code as league_cc
|
l.country_code as league_cc,
|
||||||
|
COALESCE(om.total_outcomes, 0) AS total_outcomes
|
||||||
FROM events e
|
FROM events e
|
||||||
LEFT JOIN company_event_settings ces ON e.id = ces.event_id
|
LEFT JOIN company_event_settings ces ON e.id = ces.event_id
|
||||||
JOIN leagues l ON l.id = e.league_id;
|
JOIN leagues l ON l.id = e.league_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT event_id,
|
||||||
|
SUM(number_of_outcomes) AS total_outcomes
|
||||||
|
FROM odds_market
|
||||||
|
GROUP BY event_id
|
||||||
|
) om ON om.event_id = e.id;
|
||||||
CREATE VIEW event_with_country AS
|
CREATE VIEW event_with_country AS
|
||||||
SELECT events.*,
|
SELECT events.*,
|
||||||
leagues.country_code as league_cc
|
leagues.country_code as league_cc,
|
||||||
|
COALESCE(om.total_outcomes, 0) AS total_outcomes
|
||||||
FROM events
|
FROM events
|
||||||
LEFT JOIN leagues ON leagues.id = events.league_id;
|
LEFT JOIN leagues ON leagues.id = events.league_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT event_id,
|
||||||
|
SUM(number_of_outcomes) AS total_outcomes
|
||||||
|
FROM odds_market
|
||||||
|
GROUP BY event_id
|
||||||
|
) om ON om.event_id = events.id;
|
||||||
CREATE VIEW odds_market_with_settings AS
|
CREATE VIEW odds_market_with_settings AS
|
||||||
SELECT o.id,
|
SELECT o.id,
|
||||||
o.event_id,
|
o.event_id,
|
||||||
|
|
@ -709,6 +724,7 @@ SELECT o.id,
|
||||||
o.market_name,
|
o.market_name,
|
||||||
o.market_category,
|
o.market_category,
|
||||||
o.market_id,
|
o.market_id,
|
||||||
|
o.number_of_outcomes,
|
||||||
o.default_is_active,
|
o.default_is_active,
|
||||||
o.fetched_at,
|
o.fetched_at,
|
||||||
o.expires_at,
|
o.expires_at,
|
||||||
|
|
|
||||||
|
|
@ -218,11 +218,18 @@ SELECT e.*,
|
||||||
e.default_winning_upper_limit
|
e.default_winning_upper_limit
|
||||||
) AS winning_upper_limit,
|
) AS winning_upper_limit,
|
||||||
ces.updated_at,
|
ces.updated_at,
|
||||||
l.country_code as league_cc
|
l.country_code as league_cc,
|
||||||
|
COALESCE(om.total_outcomes, 0) AS total_outcomes
|
||||||
FROM events e
|
FROM events e
|
||||||
LEFT JOIN company_event_settings ces ON e.id = ces.event_id
|
LEFT JOIN company_event_settings ces ON e.id = ces.event_id
|
||||||
AND ces.company_id = $1
|
AND ces.company_id = $1
|
||||||
JOIN leagues l ON l.id = e.league_id
|
JOIN leagues l ON l.id = e.league_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT event_id,
|
||||||
|
SUM(number_of_outcomes) AS total_outcomes
|
||||||
|
FROM odds_market
|
||||||
|
GROUP BY event_id
|
||||||
|
) om ON om.event_id = e.id
|
||||||
WHERE (
|
WHERE (
|
||||||
is_live = sqlc.narg('is_live')
|
is_live = sqlc.narg('is_live')
|
||||||
OR sqlc.narg('is_live') IS NULL
|
OR sqlc.narg('is_live') IS NULL
|
||||||
|
|
@ -292,11 +299,18 @@ SELECT e.*,
|
||||||
e.default_winning_upper_limit
|
e.default_winning_upper_limit
|
||||||
) AS winning_upper_limit,
|
) AS winning_upper_limit,
|
||||||
ces.updated_at,
|
ces.updated_at,
|
||||||
l.country_code as league_cc
|
l.country_code as league_cc,
|
||||||
|
COALESCE(om.total_outcomes, 0) AS total_outcomes
|
||||||
FROM events e
|
FROM events e
|
||||||
LEFT JOIN company_event_settings ces ON e.id = ces.event_id
|
LEFT JOIN company_event_settings ces ON e.id = ces.event_id
|
||||||
AND ces.company_id = $2
|
AND ces.company_id = $2
|
||||||
JOIN leagues l ON l.id = e.league_id
|
JOIN leagues l ON l.id = e.league_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT event_id,
|
||||||
|
SUM(number_of_outcomes) AS total_outcomes
|
||||||
|
FROM odds_market
|
||||||
|
GROUP BY event_id
|
||||||
|
) om ON om.event_id = e.id
|
||||||
WHERE e.id = $1
|
WHERE e.id = $1
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
-- name: GetSportAndLeagueIDs :one
|
-- name: GetSportAndLeagueIDs :one
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ INSERT INTO odds_market (
|
||||||
market_name,
|
market_name,
|
||||||
market_category,
|
market_category,
|
||||||
market_id,
|
market_id,
|
||||||
|
number_of_outcomes,
|
||||||
raw_odds,
|
raw_odds,
|
||||||
fetched_at,
|
fetched_at,
|
||||||
expires_at
|
expires_at
|
||||||
|
|
@ -17,13 +18,15 @@ VALUES (
|
||||||
$5,
|
$5,
|
||||||
$6,
|
$6,
|
||||||
$7,
|
$7,
|
||||||
$8
|
$8,
|
||||||
|
$9
|
||||||
) ON CONFLICT (event_id, market_id) DO
|
) ON CONFLICT (event_id, market_id) DO
|
||||||
UPDATE
|
UPDATE
|
||||||
SET market_type = EXCLUDED.market_type,
|
SET market_type = EXCLUDED.market_type,
|
||||||
market_name = EXCLUDED.market_name,
|
market_name = EXCLUDED.market_name,
|
||||||
market_category = EXCLUDED.market_category,
|
market_category = EXCLUDED.market_category,
|
||||||
raw_odds = EXCLUDED.raw_odds,
|
raw_odds = EXCLUDED.raw_odds,
|
||||||
|
number_of_outcomes = EXCLUDED.number_of_outcomes,
|
||||||
fetched_at = EXCLUDED.fetched_at,
|
fetched_at = EXCLUDED.fetched_at,
|
||||||
expires_at = EXCLUDED.expires_at;
|
expires_at = EXCLUDED.expires_at;
|
||||||
-- name: SaveOddSettings :exec
|
-- name: SaveOddSettings :exec
|
||||||
|
|
@ -48,6 +51,7 @@ SELECT o.id,
|
||||||
o.market_name,
|
o.market_name,
|
||||||
o.market_category,
|
o.market_category,
|
||||||
o.market_id,
|
o.market_id,
|
||||||
|
o.number_of_outcomes,
|
||||||
o.default_is_active,
|
o.default_is_active,
|
||||||
o.fetched_at,
|
o.fetched_at,
|
||||||
o.expires_at,
|
o.expires_at,
|
||||||
|
|
@ -75,6 +79,7 @@ SELECT o.id,
|
||||||
o.market_name,
|
o.market_name,
|
||||||
o.market_category,
|
o.market_category,
|
||||||
o.market_id,
|
o.market_id,
|
||||||
|
o.number_of_outcomes,
|
||||||
o.default_is_active,
|
o.default_is_active,
|
||||||
o.fetched_at,
|
o.fetched_at,
|
||||||
o.expires_at,
|
o.expires_at,
|
||||||
|
|
@ -94,6 +99,7 @@ SELECT o.id,
|
||||||
o.market_name,
|
o.market_name,
|
||||||
o.market_category,
|
o.market_category,
|
||||||
o.market_id,
|
o.market_id,
|
||||||
|
o.number_of_outcomes,
|
||||||
o.default_is_active,
|
o.default_is_active,
|
||||||
o.fetched_at,
|
o.fetched_at,
|
||||||
o.expires_at,
|
o.expires_at,
|
||||||
|
|
@ -129,6 +135,7 @@ SELECT o.id,
|
||||||
o.market_name,
|
o.market_name,
|
||||||
o.market_category,
|
o.market_category,
|
||||||
o.market_id,
|
o.market_id,
|
||||||
|
o.number_of_outcomes,
|
||||||
o.default_is_active,
|
o.default_is_active,
|
||||||
o.fetched_at,
|
o.fetched_at,
|
||||||
o.expires_at,
|
o.expires_at,
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ func (q *Queries) DeleteEvent(ctx context.Context, id int64) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
const GetAllEvents = `-- name: GetAllEvents :many
|
const GetAllEvents = `-- name: GetAllEvents :many
|
||||||
SELECT id, source_event_id, sport_id, match_name, home_team, away_team, home_team_id, away_team_id, home_kit_image, away_kit_image, league_id, league_name, start_time, score, match_minute, timer_status, added_time, match_period, is_live, status, fetched_at, updated_at, source, default_is_active, default_is_featured, default_winning_upper_limit, is_monitored, league_cc
|
SELECT id, source_event_id, sport_id, match_name, home_team, away_team, home_team_id, away_team_id, home_kit_image, away_kit_image, league_id, league_name, start_time, score, match_minute, timer_status, added_time, match_period, is_live, status, fetched_at, updated_at, source, default_is_active, default_is_featured, default_winning_upper_limit, is_monitored, league_cc, total_outcomes
|
||||||
FROM event_with_country
|
FROM event_with_country
|
||||||
WHERE (
|
WHERE (
|
||||||
is_live = $1
|
is_live = $1
|
||||||
|
|
@ -129,6 +129,7 @@ func (q *Queries) GetAllEvents(ctx context.Context, arg GetAllEventsParams) ([]E
|
||||||
&i.DefaultWinningUpperLimit,
|
&i.DefaultWinningUpperLimit,
|
||||||
&i.IsMonitored,
|
&i.IsMonitored,
|
||||||
&i.LeagueCc,
|
&i.LeagueCc,
|
||||||
|
&i.TotalOutcomes,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -141,7 +142,7 @@ func (q *Queries) GetAllEvents(ctx context.Context, arg GetAllEventsParams) ([]E
|
||||||
}
|
}
|
||||||
|
|
||||||
const GetEventByID = `-- name: GetEventByID :one
|
const GetEventByID = `-- name: GetEventByID :one
|
||||||
SELECT id, source_event_id, sport_id, match_name, home_team, away_team, home_team_id, away_team_id, home_kit_image, away_kit_image, league_id, league_name, start_time, score, match_minute, timer_status, added_time, match_period, is_live, status, fetched_at, updated_at, source, default_is_active, default_is_featured, default_winning_upper_limit, is_monitored, league_cc
|
SELECT id, source_event_id, sport_id, match_name, home_team, away_team, home_team_id, away_team_id, home_kit_image, away_kit_image, league_id, league_name, start_time, score, match_minute, timer_status, added_time, match_period, is_live, status, fetched_at, updated_at, source, default_is_active, default_is_featured, default_winning_upper_limit, is_monitored, league_cc, total_outcomes
|
||||||
FROM event_with_country
|
FROM event_with_country
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
|
|
@ -179,12 +180,13 @@ func (q *Queries) GetEventByID(ctx context.Context, id int64) (EventWithCountry,
|
||||||
&i.DefaultWinningUpperLimit,
|
&i.DefaultWinningUpperLimit,
|
||||||
&i.IsMonitored,
|
&i.IsMonitored,
|
||||||
&i.LeagueCc,
|
&i.LeagueCc,
|
||||||
|
&i.TotalOutcomes,
|
||||||
)
|
)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
|
|
||||||
const GetEventBySourceID = `-- name: GetEventBySourceID :one
|
const GetEventBySourceID = `-- name: GetEventBySourceID :one
|
||||||
SELECT id, source_event_id, sport_id, match_name, home_team, away_team, home_team_id, away_team_id, home_kit_image, away_kit_image, league_id, league_name, start_time, score, match_minute, timer_status, added_time, match_period, is_live, status, fetched_at, updated_at, source, default_is_active, default_is_featured, default_winning_upper_limit, is_monitored, league_cc
|
SELECT id, source_event_id, sport_id, match_name, home_team, away_team, home_team_id, away_team_id, home_kit_image, away_kit_image, league_id, league_name, start_time, score, match_minute, timer_status, added_time, match_period, is_live, status, fetched_at, updated_at, source, default_is_active, default_is_featured, default_winning_upper_limit, is_monitored, league_cc, total_outcomes
|
||||||
FROM event_with_country
|
FROM event_with_country
|
||||||
WHERE source_event_id = $1
|
WHERE source_event_id = $1
|
||||||
AND source = $2
|
AND source = $2
|
||||||
|
|
@ -227,6 +229,7 @@ func (q *Queries) GetEventBySourceID(ctx context.Context, arg GetEventBySourceID
|
||||||
&i.DefaultWinningUpperLimit,
|
&i.DefaultWinningUpperLimit,
|
||||||
&i.IsMonitored,
|
&i.IsMonitored,
|
||||||
&i.LeagueCc,
|
&i.LeagueCc,
|
||||||
|
&i.TotalOutcomes,
|
||||||
)
|
)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
|
|
@ -241,11 +244,18 @@ SELECT e.id, e.source_event_id, e.sport_id, e.match_name, e.home_team, e.away_te
|
||||||
e.default_winning_upper_limit
|
e.default_winning_upper_limit
|
||||||
) AS winning_upper_limit,
|
) AS winning_upper_limit,
|
||||||
ces.updated_at,
|
ces.updated_at,
|
||||||
l.country_code as league_cc
|
l.country_code as league_cc,
|
||||||
|
COALESCE(om.total_outcomes, 0) AS total_outcomes
|
||||||
FROM events e
|
FROM events e
|
||||||
LEFT JOIN company_event_settings ces ON e.id = ces.event_id
|
LEFT JOIN company_event_settings ces ON e.id = ces.event_id
|
||||||
AND ces.company_id = $2
|
AND ces.company_id = $2
|
||||||
JOIN leagues l ON l.id = e.league_id
|
JOIN leagues l ON l.id = e.league_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT event_id,
|
||||||
|
SUM(number_of_outcomes) AS total_outcomes
|
||||||
|
FROM odds_market
|
||||||
|
GROUP BY event_id
|
||||||
|
) om ON om.event_id = e.id
|
||||||
WHERE e.id = $1
|
WHERE e.id = $1
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
`
|
`
|
||||||
|
|
@ -289,6 +299,7 @@ type GetEventWithSettingByIDRow struct {
|
||||||
WinningUpperLimit int64 `json:"winning_upper_limit"`
|
WinningUpperLimit int64 `json:"winning_upper_limit"`
|
||||||
UpdatedAt_2 pgtype.Timestamp `json:"updated_at_2"`
|
UpdatedAt_2 pgtype.Timestamp `json:"updated_at_2"`
|
||||||
LeagueCc pgtype.Text `json:"league_cc"`
|
LeagueCc pgtype.Text `json:"league_cc"`
|
||||||
|
TotalOutcomes int64 `json:"total_outcomes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) GetEventWithSettingByID(ctx context.Context, arg GetEventWithSettingByIDParams) (GetEventWithSettingByIDRow, error) {
|
func (q *Queries) GetEventWithSettingByID(ctx context.Context, arg GetEventWithSettingByIDParams) (GetEventWithSettingByIDRow, error) {
|
||||||
|
|
@ -328,6 +339,7 @@ func (q *Queries) GetEventWithSettingByID(ctx context.Context, arg GetEventWithS
|
||||||
&i.WinningUpperLimit,
|
&i.WinningUpperLimit,
|
||||||
&i.UpdatedAt_2,
|
&i.UpdatedAt_2,
|
||||||
&i.LeagueCc,
|
&i.LeagueCc,
|
||||||
|
&i.TotalOutcomes,
|
||||||
)
|
)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
|
|
@ -342,11 +354,18 @@ SELECT e.id, e.source_event_id, e.sport_id, e.match_name, e.home_team, e.away_te
|
||||||
e.default_winning_upper_limit
|
e.default_winning_upper_limit
|
||||||
) AS winning_upper_limit,
|
) AS winning_upper_limit,
|
||||||
ces.updated_at,
|
ces.updated_at,
|
||||||
l.country_code as league_cc
|
l.country_code as league_cc,
|
||||||
|
COALESCE(om.total_outcomes, 0) AS total_outcomes
|
||||||
FROM events e
|
FROM events e
|
||||||
LEFT JOIN company_event_settings ces ON e.id = ces.event_id
|
LEFT JOIN company_event_settings ces ON e.id = ces.event_id
|
||||||
AND ces.company_id = $1
|
AND ces.company_id = $1
|
||||||
JOIN leagues l ON l.id = e.league_id
|
JOIN leagues l ON l.id = e.league_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT event_id,
|
||||||
|
SUM(number_of_outcomes) AS total_outcomes
|
||||||
|
FROM odds_market
|
||||||
|
GROUP BY event_id
|
||||||
|
) om ON om.event_id = e.id
|
||||||
WHERE (
|
WHERE (
|
||||||
is_live = $2
|
is_live = $2
|
||||||
OR $2 IS NULL
|
OR $2 IS NULL
|
||||||
|
|
@ -449,6 +468,7 @@ type GetEventsWithSettingsRow struct {
|
||||||
WinningUpperLimit int64 `json:"winning_upper_limit"`
|
WinningUpperLimit int64 `json:"winning_upper_limit"`
|
||||||
UpdatedAt_2 pgtype.Timestamp `json:"updated_at_2"`
|
UpdatedAt_2 pgtype.Timestamp `json:"updated_at_2"`
|
||||||
LeagueCc pgtype.Text `json:"league_cc"`
|
LeagueCc pgtype.Text `json:"league_cc"`
|
||||||
|
TotalOutcomes int64 `json:"total_outcomes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) GetEventsWithSettings(ctx context.Context, arg GetEventsWithSettingsParams) ([]GetEventsWithSettingsRow, error) {
|
func (q *Queries) GetEventsWithSettings(ctx context.Context, arg GetEventsWithSettingsParams) ([]GetEventsWithSettingsRow, error) {
|
||||||
|
|
@ -509,6 +529,7 @@ func (q *Queries) GetEventsWithSettings(ctx context.Context, arg GetEventsWithSe
|
||||||
&i.WinningUpperLimit,
|
&i.WinningUpperLimit,
|
||||||
&i.UpdatedAt_2,
|
&i.UpdatedAt_2,
|
||||||
&i.LeagueCc,
|
&i.LeagueCc,
|
||||||
|
&i.TotalOutcomes,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -376,6 +376,7 @@ type EventWithCountry struct {
|
||||||
DefaultWinningUpperLimit int64 `json:"default_winning_upper_limit"`
|
DefaultWinningUpperLimit int64 `json:"default_winning_upper_limit"`
|
||||||
IsMonitored bool `json:"is_monitored"`
|
IsMonitored bool `json:"is_monitored"`
|
||||||
LeagueCc pgtype.Text `json:"league_cc"`
|
LeagueCc pgtype.Text `json:"league_cc"`
|
||||||
|
TotalOutcomes int64 `json:"total_outcomes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type EventWithSetting struct {
|
type EventWithSetting struct {
|
||||||
|
|
@ -412,6 +413,7 @@ type EventWithSetting struct {
|
||||||
WinningUpperLimit int64 `json:"winning_upper_limit"`
|
WinningUpperLimit int64 `json:"winning_upper_limit"`
|
||||||
CompanyUpdatedAt pgtype.Timestamp `json:"company_updated_at"`
|
CompanyUpdatedAt pgtype.Timestamp `json:"company_updated_at"`
|
||||||
LeagueCc pgtype.Text `json:"league_cc"`
|
LeagueCc pgtype.Text `json:"league_cc"`
|
||||||
|
TotalOutcomes int64 `json:"total_outcomes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ExchangeRate struct {
|
type ExchangeRate struct {
|
||||||
|
|
@ -502,49 +504,52 @@ type OddHistory struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type OddsMarket struct {
|
type OddsMarket struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
EventID int64 `json:"event_id"`
|
EventID int64 `json:"event_id"`
|
||||||
MarketType string `json:"market_type"`
|
MarketType string `json:"market_type"`
|
||||||
MarketName string `json:"market_name"`
|
MarketName string `json:"market_name"`
|
||||||
MarketCategory string `json:"market_category"`
|
MarketCategory string `json:"market_category"`
|
||||||
MarketID int64 `json:"market_id"`
|
MarketID int64 `json:"market_id"`
|
||||||
RawOdds []byte `json:"raw_odds"`
|
RawOdds []byte `json:"raw_odds"`
|
||||||
DefaultIsActive bool `json:"default_is_active"`
|
NumberOfOutcomes int64 `json:"number_of_outcomes"`
|
||||||
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
DefaultIsActive bool `json:"default_is_active"`
|
||||||
ExpiresAt pgtype.Timestamp `json:"expires_at"`
|
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
||||||
|
ExpiresAt pgtype.Timestamp `json:"expires_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type OddsMarketWithEvent struct {
|
type OddsMarketWithEvent struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
EventID int64 `json:"event_id"`
|
EventID int64 `json:"event_id"`
|
||||||
MarketType string `json:"market_type"`
|
MarketType string `json:"market_type"`
|
||||||
MarketName string `json:"market_name"`
|
MarketName string `json:"market_name"`
|
||||||
MarketCategory string `json:"market_category"`
|
MarketCategory string `json:"market_category"`
|
||||||
MarketID int64 `json:"market_id"`
|
MarketID int64 `json:"market_id"`
|
||||||
RawOdds []byte `json:"raw_odds"`
|
RawOdds []byte `json:"raw_odds"`
|
||||||
DefaultIsActive bool `json:"default_is_active"`
|
NumberOfOutcomes int64 `json:"number_of_outcomes"`
|
||||||
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
DefaultIsActive bool `json:"default_is_active"`
|
||||||
ExpiresAt pgtype.Timestamp `json:"expires_at"`
|
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
||||||
IsMonitored bool `json:"is_monitored"`
|
ExpiresAt pgtype.Timestamp `json:"expires_at"`
|
||||||
IsLive bool `json:"is_live"`
|
IsMonitored bool `json:"is_monitored"`
|
||||||
Status string `json:"status"`
|
IsLive bool `json:"is_live"`
|
||||||
Source string `json:"source"`
|
Status string `json:"status"`
|
||||||
|
Source string `json:"source"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type OddsMarketWithSetting struct {
|
type OddsMarketWithSetting struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
EventID int64 `json:"event_id"`
|
EventID int64 `json:"event_id"`
|
||||||
MarketType string `json:"market_type"`
|
MarketType string `json:"market_type"`
|
||||||
MarketName string `json:"market_name"`
|
MarketName string `json:"market_name"`
|
||||||
MarketCategory string `json:"market_category"`
|
MarketCategory string `json:"market_category"`
|
||||||
MarketID int64 `json:"market_id"`
|
MarketID int64 `json:"market_id"`
|
||||||
DefaultIsActive bool `json:"default_is_active"`
|
NumberOfOutcomes int64 `json:"number_of_outcomes"`
|
||||||
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
DefaultIsActive bool `json:"default_is_active"`
|
||||||
ExpiresAt pgtype.Timestamp `json:"expires_at"`
|
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
||||||
CompanyID pgtype.Int8 `json:"company_id"`
|
ExpiresAt pgtype.Timestamp `json:"expires_at"`
|
||||||
IsActive bool `json:"is_active"`
|
CompanyID pgtype.Int8 `json:"company_id"`
|
||||||
RawOdds []byte `json:"raw_odds"`
|
IsActive bool `json:"is_active"`
|
||||||
UpdatedAt pgtype.Timestamp `json:"updated_at"`
|
RawOdds []byte `json:"raw_odds"`
|
||||||
|
UpdatedAt pgtype.Timestamp `json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Otp struct {
|
type Otp struct {
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ func (q *Queries) DeleteOddsForEvent(ctx context.Context, eventID int64) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
const GetAllOdds = `-- name: GetAllOdds :many
|
const GetAllOdds = `-- name: GetAllOdds :many
|
||||||
SELECT id, event_id, market_type, market_name, market_category, market_id, raw_odds, default_is_active, fetched_at, expires_at, is_monitored, is_live, status, source
|
SELECT id, event_id, market_type, market_name, market_category, market_id, raw_odds, number_of_outcomes, default_is_active, fetched_at, expires_at, is_monitored, is_live, status, source
|
||||||
FROM odds_market_with_event
|
FROM odds_market_with_event
|
||||||
LIMIT $2 OFFSET $1
|
LIMIT $2 OFFSET $1
|
||||||
`
|
`
|
||||||
|
|
@ -75,6 +75,7 @@ func (q *Queries) GetAllOdds(ctx context.Context, arg GetAllOddsParams) ([]OddsM
|
||||||
&i.MarketCategory,
|
&i.MarketCategory,
|
||||||
&i.MarketID,
|
&i.MarketID,
|
||||||
&i.RawOdds,
|
&i.RawOdds,
|
||||||
|
&i.NumberOfOutcomes,
|
||||||
&i.DefaultIsActive,
|
&i.DefaultIsActive,
|
||||||
&i.FetchedAt,
|
&i.FetchedAt,
|
||||||
&i.ExpiresAt,
|
&i.ExpiresAt,
|
||||||
|
|
@ -100,6 +101,7 @@ SELECT o.id,
|
||||||
o.market_name,
|
o.market_name,
|
||||||
o.market_category,
|
o.market_category,
|
||||||
o.market_id,
|
o.market_id,
|
||||||
|
o.number_of_outcomes,
|
||||||
o.default_is_active,
|
o.default_is_active,
|
||||||
o.fetched_at,
|
o.fetched_at,
|
||||||
o.expires_at,
|
o.expires_at,
|
||||||
|
|
@ -120,19 +122,20 @@ type GetAllOddsWithSettingsParams struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetAllOddsWithSettingsRow struct {
|
type GetAllOddsWithSettingsRow struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
EventID int64 `json:"event_id"`
|
EventID int64 `json:"event_id"`
|
||||||
MarketType string `json:"market_type"`
|
MarketType string `json:"market_type"`
|
||||||
MarketName string `json:"market_name"`
|
MarketName string `json:"market_name"`
|
||||||
MarketCategory string `json:"market_category"`
|
MarketCategory string `json:"market_category"`
|
||||||
MarketID int64 `json:"market_id"`
|
MarketID int64 `json:"market_id"`
|
||||||
DefaultIsActive bool `json:"default_is_active"`
|
NumberOfOutcomes int64 `json:"number_of_outcomes"`
|
||||||
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
DefaultIsActive bool `json:"default_is_active"`
|
||||||
ExpiresAt pgtype.Timestamp `json:"expires_at"`
|
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
||||||
CompanyID pgtype.Int8 `json:"company_id"`
|
ExpiresAt pgtype.Timestamp `json:"expires_at"`
|
||||||
IsActive bool `json:"is_active"`
|
CompanyID pgtype.Int8 `json:"company_id"`
|
||||||
RawOdds []byte `json:"raw_odds"`
|
IsActive bool `json:"is_active"`
|
||||||
UpdatedAt pgtype.Timestamp `json:"updated_at"`
|
RawOdds []byte `json:"raw_odds"`
|
||||||
|
UpdatedAt pgtype.Timestamp `json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) GetAllOddsWithSettings(ctx context.Context, arg GetAllOddsWithSettingsParams) ([]GetAllOddsWithSettingsRow, error) {
|
func (q *Queries) GetAllOddsWithSettings(ctx context.Context, arg GetAllOddsWithSettingsParams) ([]GetAllOddsWithSettingsRow, error) {
|
||||||
|
|
@ -151,6 +154,7 @@ func (q *Queries) GetAllOddsWithSettings(ctx context.Context, arg GetAllOddsWith
|
||||||
&i.MarketName,
|
&i.MarketName,
|
||||||
&i.MarketCategory,
|
&i.MarketCategory,
|
||||||
&i.MarketID,
|
&i.MarketID,
|
||||||
|
&i.NumberOfOutcomes,
|
||||||
&i.DefaultIsActive,
|
&i.DefaultIsActive,
|
||||||
&i.FetchedAt,
|
&i.FetchedAt,
|
||||||
&i.ExpiresAt,
|
&i.ExpiresAt,
|
||||||
|
|
@ -170,7 +174,7 @@ func (q *Queries) GetAllOddsWithSettings(ctx context.Context, arg GetAllOddsWith
|
||||||
}
|
}
|
||||||
|
|
||||||
const GetOddByID = `-- name: GetOddByID :one
|
const GetOddByID = `-- name: GetOddByID :one
|
||||||
SELECT id, event_id, market_type, market_name, market_category, market_id, raw_odds, default_is_active, fetched_at, expires_at, is_monitored, is_live, status, source
|
SELECT id, event_id, market_type, market_name, market_category, market_id, raw_odds, number_of_outcomes, default_is_active, fetched_at, expires_at, is_monitored, is_live, status, source
|
||||||
FROM odds_market_with_event
|
FROM odds_market_with_event
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
`
|
`
|
||||||
|
|
@ -186,6 +190,7 @@ func (q *Queries) GetOddByID(ctx context.Context, id int64) (OddsMarketWithEvent
|
||||||
&i.MarketCategory,
|
&i.MarketCategory,
|
||||||
&i.MarketID,
|
&i.MarketID,
|
||||||
&i.RawOdds,
|
&i.RawOdds,
|
||||||
|
&i.NumberOfOutcomes,
|
||||||
&i.DefaultIsActive,
|
&i.DefaultIsActive,
|
||||||
&i.FetchedAt,
|
&i.FetchedAt,
|
||||||
&i.ExpiresAt,
|
&i.ExpiresAt,
|
||||||
|
|
@ -198,7 +203,7 @@ func (q *Queries) GetOddByID(ctx context.Context, id int64) (OddsMarketWithEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
const GetOddsByEventID = `-- name: GetOddsByEventID :many
|
const GetOddsByEventID = `-- name: GetOddsByEventID :many
|
||||||
SELECT id, event_id, market_type, market_name, market_category, market_id, raw_odds, default_is_active, fetched_at, expires_at, is_monitored, is_live, status, source
|
SELECT id, event_id, market_type, market_name, market_category, market_id, raw_odds, number_of_outcomes, default_is_active, fetched_at, expires_at, is_monitored, is_live, status, source
|
||||||
FROM odds_market_with_event
|
FROM odds_market_with_event
|
||||||
WHERE event_id = $1
|
WHERE event_id = $1
|
||||||
AND (
|
AND (
|
||||||
|
|
@ -249,6 +254,7 @@ func (q *Queries) GetOddsByEventID(ctx context.Context, arg GetOddsByEventIDPara
|
||||||
&i.MarketCategory,
|
&i.MarketCategory,
|
||||||
&i.MarketID,
|
&i.MarketID,
|
||||||
&i.RawOdds,
|
&i.RawOdds,
|
||||||
|
&i.NumberOfOutcomes,
|
||||||
&i.DefaultIsActive,
|
&i.DefaultIsActive,
|
||||||
&i.FetchedAt,
|
&i.FetchedAt,
|
||||||
&i.ExpiresAt,
|
&i.ExpiresAt,
|
||||||
|
|
@ -268,7 +274,7 @@ func (q *Queries) GetOddsByEventID(ctx context.Context, arg GetOddsByEventIDPara
|
||||||
}
|
}
|
||||||
|
|
||||||
const GetOddsByMarketID = `-- name: GetOddsByMarketID :one
|
const GetOddsByMarketID = `-- name: GetOddsByMarketID :one
|
||||||
SELECT id, event_id, market_type, market_name, market_category, market_id, raw_odds, default_is_active, fetched_at, expires_at, is_monitored, is_live, status, source
|
SELECT id, event_id, market_type, market_name, market_category, market_id, raw_odds, number_of_outcomes, default_is_active, fetched_at, expires_at, is_monitored, is_live, status, source
|
||||||
FROM odds_market_with_event
|
FROM odds_market_with_event
|
||||||
WHERE market_id = $1
|
WHERE market_id = $1
|
||||||
AND event_id = $2
|
AND event_id = $2
|
||||||
|
|
@ -290,6 +296,7 @@ func (q *Queries) GetOddsByMarketID(ctx context.Context, arg GetOddsByMarketIDPa
|
||||||
&i.MarketCategory,
|
&i.MarketCategory,
|
||||||
&i.MarketID,
|
&i.MarketID,
|
||||||
&i.RawOdds,
|
&i.RawOdds,
|
||||||
|
&i.NumberOfOutcomes,
|
||||||
&i.DefaultIsActive,
|
&i.DefaultIsActive,
|
||||||
&i.FetchedAt,
|
&i.FetchedAt,
|
||||||
&i.ExpiresAt,
|
&i.ExpiresAt,
|
||||||
|
|
@ -308,6 +315,7 @@ SELECT o.id,
|
||||||
o.market_name,
|
o.market_name,
|
||||||
o.market_category,
|
o.market_category,
|
||||||
o.market_id,
|
o.market_id,
|
||||||
|
o.number_of_outcomes,
|
||||||
o.default_is_active,
|
o.default_is_active,
|
||||||
o.fetched_at,
|
o.fetched_at,
|
||||||
o.expires_at,
|
o.expires_at,
|
||||||
|
|
@ -330,19 +338,20 @@ type GetOddsWithSettingsByEventIDParams struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetOddsWithSettingsByEventIDRow struct {
|
type GetOddsWithSettingsByEventIDRow struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
EventID int64 `json:"event_id"`
|
EventID int64 `json:"event_id"`
|
||||||
MarketType string `json:"market_type"`
|
MarketType string `json:"market_type"`
|
||||||
MarketName string `json:"market_name"`
|
MarketName string `json:"market_name"`
|
||||||
MarketCategory string `json:"market_category"`
|
MarketCategory string `json:"market_category"`
|
||||||
MarketID int64 `json:"market_id"`
|
MarketID int64 `json:"market_id"`
|
||||||
DefaultIsActive bool `json:"default_is_active"`
|
NumberOfOutcomes int64 `json:"number_of_outcomes"`
|
||||||
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
DefaultIsActive bool `json:"default_is_active"`
|
||||||
ExpiresAt pgtype.Timestamp `json:"expires_at"`
|
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
||||||
CompanyID pgtype.Int8 `json:"company_id"`
|
ExpiresAt pgtype.Timestamp `json:"expires_at"`
|
||||||
IsActive bool `json:"is_active"`
|
CompanyID pgtype.Int8 `json:"company_id"`
|
||||||
RawOdds []byte `json:"raw_odds"`
|
IsActive bool `json:"is_active"`
|
||||||
UpdatedAt pgtype.Timestamp `json:"updated_at"`
|
RawOdds []byte `json:"raw_odds"`
|
||||||
|
UpdatedAt pgtype.Timestamp `json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) GetOddsWithSettingsByEventID(ctx context.Context, arg GetOddsWithSettingsByEventIDParams) ([]GetOddsWithSettingsByEventIDRow, error) {
|
func (q *Queries) GetOddsWithSettingsByEventID(ctx context.Context, arg GetOddsWithSettingsByEventIDParams) ([]GetOddsWithSettingsByEventIDRow, error) {
|
||||||
|
|
@ -366,6 +375,7 @@ func (q *Queries) GetOddsWithSettingsByEventID(ctx context.Context, arg GetOddsW
|
||||||
&i.MarketName,
|
&i.MarketName,
|
||||||
&i.MarketCategory,
|
&i.MarketCategory,
|
||||||
&i.MarketID,
|
&i.MarketID,
|
||||||
|
&i.NumberOfOutcomes,
|
||||||
&i.DefaultIsActive,
|
&i.DefaultIsActive,
|
||||||
&i.FetchedAt,
|
&i.FetchedAt,
|
||||||
&i.ExpiresAt,
|
&i.ExpiresAt,
|
||||||
|
|
@ -391,6 +401,7 @@ SELECT o.id,
|
||||||
o.market_name,
|
o.market_name,
|
||||||
o.market_category,
|
o.market_category,
|
||||||
o.market_id,
|
o.market_id,
|
||||||
|
o.number_of_outcomes,
|
||||||
o.default_is_active,
|
o.default_is_active,
|
||||||
o.fetched_at,
|
o.fetched_at,
|
||||||
o.expires_at,
|
o.expires_at,
|
||||||
|
|
@ -410,19 +421,20 @@ type GetOddsWithSettingsByIDParams struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetOddsWithSettingsByIDRow struct {
|
type GetOddsWithSettingsByIDRow struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
EventID int64 `json:"event_id"`
|
EventID int64 `json:"event_id"`
|
||||||
MarketType string `json:"market_type"`
|
MarketType string `json:"market_type"`
|
||||||
MarketName string `json:"market_name"`
|
MarketName string `json:"market_name"`
|
||||||
MarketCategory string `json:"market_category"`
|
MarketCategory string `json:"market_category"`
|
||||||
MarketID int64 `json:"market_id"`
|
MarketID int64 `json:"market_id"`
|
||||||
DefaultIsActive bool `json:"default_is_active"`
|
NumberOfOutcomes int64 `json:"number_of_outcomes"`
|
||||||
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
DefaultIsActive bool `json:"default_is_active"`
|
||||||
ExpiresAt pgtype.Timestamp `json:"expires_at"`
|
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
||||||
CompanyID pgtype.Int8 `json:"company_id"`
|
ExpiresAt pgtype.Timestamp `json:"expires_at"`
|
||||||
IsActive bool `json:"is_active"`
|
CompanyID pgtype.Int8 `json:"company_id"`
|
||||||
RawOdds []byte `json:"raw_odds"`
|
IsActive bool `json:"is_active"`
|
||||||
UpdatedAt pgtype.Timestamp `json:"updated_at"`
|
RawOdds []byte `json:"raw_odds"`
|
||||||
|
UpdatedAt pgtype.Timestamp `json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) GetOddsWithSettingsByID(ctx context.Context, arg GetOddsWithSettingsByIDParams) (GetOddsWithSettingsByIDRow, error) {
|
func (q *Queries) GetOddsWithSettingsByID(ctx context.Context, arg GetOddsWithSettingsByIDParams) (GetOddsWithSettingsByIDRow, error) {
|
||||||
|
|
@ -435,6 +447,7 @@ func (q *Queries) GetOddsWithSettingsByID(ctx context.Context, arg GetOddsWithSe
|
||||||
&i.MarketName,
|
&i.MarketName,
|
||||||
&i.MarketCategory,
|
&i.MarketCategory,
|
||||||
&i.MarketID,
|
&i.MarketID,
|
||||||
|
&i.NumberOfOutcomes,
|
||||||
&i.DefaultIsActive,
|
&i.DefaultIsActive,
|
||||||
&i.FetchedAt,
|
&i.FetchedAt,
|
||||||
&i.ExpiresAt,
|
&i.ExpiresAt,
|
||||||
|
|
@ -453,6 +466,7 @@ SELECT o.id,
|
||||||
o.market_name,
|
o.market_name,
|
||||||
o.market_category,
|
o.market_category,
|
||||||
o.market_id,
|
o.market_id,
|
||||||
|
o.number_of_outcomes,
|
||||||
o.default_is_active,
|
o.default_is_active,
|
||||||
o.fetched_at,
|
o.fetched_at,
|
||||||
o.expires_at,
|
o.expires_at,
|
||||||
|
|
@ -474,19 +488,20 @@ type GetOddsWithSettingsByMarketIDParams struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetOddsWithSettingsByMarketIDRow struct {
|
type GetOddsWithSettingsByMarketIDRow struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
EventID int64 `json:"event_id"`
|
EventID int64 `json:"event_id"`
|
||||||
MarketType string `json:"market_type"`
|
MarketType string `json:"market_type"`
|
||||||
MarketName string `json:"market_name"`
|
MarketName string `json:"market_name"`
|
||||||
MarketCategory string `json:"market_category"`
|
MarketCategory string `json:"market_category"`
|
||||||
MarketID int64 `json:"market_id"`
|
MarketID int64 `json:"market_id"`
|
||||||
DefaultIsActive bool `json:"default_is_active"`
|
NumberOfOutcomes int64 `json:"number_of_outcomes"`
|
||||||
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
DefaultIsActive bool `json:"default_is_active"`
|
||||||
ExpiresAt pgtype.Timestamp `json:"expires_at"`
|
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
||||||
CompanyID pgtype.Int8 `json:"company_id"`
|
ExpiresAt pgtype.Timestamp `json:"expires_at"`
|
||||||
IsActive bool `json:"is_active"`
|
CompanyID pgtype.Int8 `json:"company_id"`
|
||||||
RawOdds []byte `json:"raw_odds"`
|
IsActive bool `json:"is_active"`
|
||||||
UpdatedAt pgtype.Timestamp `json:"updated_at"`
|
RawOdds []byte `json:"raw_odds"`
|
||||||
|
UpdatedAt pgtype.Timestamp `json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) GetOddsWithSettingsByMarketID(ctx context.Context, arg GetOddsWithSettingsByMarketIDParams) (GetOddsWithSettingsByMarketIDRow, error) {
|
func (q *Queries) GetOddsWithSettingsByMarketID(ctx context.Context, arg GetOddsWithSettingsByMarketIDParams) (GetOddsWithSettingsByMarketIDRow, error) {
|
||||||
|
|
@ -499,6 +514,7 @@ func (q *Queries) GetOddsWithSettingsByMarketID(ctx context.Context, arg GetOdds
|
||||||
&i.MarketName,
|
&i.MarketName,
|
||||||
&i.MarketCategory,
|
&i.MarketCategory,
|
||||||
&i.MarketID,
|
&i.MarketID,
|
||||||
|
&i.NumberOfOutcomes,
|
||||||
&i.DefaultIsActive,
|
&i.DefaultIsActive,
|
||||||
&i.FetchedAt,
|
&i.FetchedAt,
|
||||||
&i.ExpiresAt,
|
&i.ExpiresAt,
|
||||||
|
|
@ -517,6 +533,7 @@ INSERT INTO odds_market (
|
||||||
market_name,
|
market_name,
|
||||||
market_category,
|
market_category,
|
||||||
market_id,
|
market_id,
|
||||||
|
number_of_outcomes,
|
||||||
raw_odds,
|
raw_odds,
|
||||||
fetched_at,
|
fetched_at,
|
||||||
expires_at
|
expires_at
|
||||||
|
|
@ -529,26 +546,29 @@ VALUES (
|
||||||
$5,
|
$5,
|
||||||
$6,
|
$6,
|
||||||
$7,
|
$7,
|
||||||
$8
|
$8,
|
||||||
|
$9
|
||||||
) ON CONFLICT (event_id, market_id) DO
|
) ON CONFLICT (event_id, market_id) DO
|
||||||
UPDATE
|
UPDATE
|
||||||
SET market_type = EXCLUDED.market_type,
|
SET market_type = EXCLUDED.market_type,
|
||||||
market_name = EXCLUDED.market_name,
|
market_name = EXCLUDED.market_name,
|
||||||
market_category = EXCLUDED.market_category,
|
market_category = EXCLUDED.market_category,
|
||||||
raw_odds = EXCLUDED.raw_odds,
|
raw_odds = EXCLUDED.raw_odds,
|
||||||
|
number_of_outcomes = EXCLUDED.number_of_outcomes,
|
||||||
fetched_at = EXCLUDED.fetched_at,
|
fetched_at = EXCLUDED.fetched_at,
|
||||||
expires_at = EXCLUDED.expires_at
|
expires_at = EXCLUDED.expires_at
|
||||||
`
|
`
|
||||||
|
|
||||||
type InsertOddsMarketParams struct {
|
type InsertOddsMarketParams struct {
|
||||||
EventID int64 `json:"event_id"`
|
EventID int64 `json:"event_id"`
|
||||||
MarketType string `json:"market_type"`
|
MarketType string `json:"market_type"`
|
||||||
MarketName string `json:"market_name"`
|
MarketName string `json:"market_name"`
|
||||||
MarketCategory string `json:"market_category"`
|
MarketCategory string `json:"market_category"`
|
||||||
MarketID int64 `json:"market_id"`
|
MarketID int64 `json:"market_id"`
|
||||||
RawOdds []byte `json:"raw_odds"`
|
NumberOfOutcomes int64 `json:"number_of_outcomes"`
|
||||||
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
RawOdds []byte `json:"raw_odds"`
|
||||||
ExpiresAt pgtype.Timestamp `json:"expires_at"`
|
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
||||||
|
ExpiresAt pgtype.Timestamp `json:"expires_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) InsertOddsMarket(ctx context.Context, arg InsertOddsMarketParams) error {
|
func (q *Queries) InsertOddsMarket(ctx context.Context, arg InsertOddsMarketParams) error {
|
||||||
|
|
@ -558,6 +578,7 @@ func (q *Queries) InsertOddsMarket(ctx context.Context, arg InsertOddsMarketPara
|
||||||
arg.MarketName,
|
arg.MarketName,
|
||||||
arg.MarketCategory,
|
arg.MarketCategory,
|
||||||
arg.MarketID,
|
arg.MarketID,
|
||||||
|
arg.NumberOfOutcomes,
|
||||||
arg.RawOdds,
|
arg.RawOdds,
|
||||||
arg.FetchedAt,
|
arg.FetchedAt,
|
||||||
arg.ExpiresAt,
|
arg.ExpiresAt,
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,7 @@ type BaseEvent struct {
|
||||||
StartTime time.Time
|
StartTime time.Time
|
||||||
Source EventSource
|
Source EventSource
|
||||||
Status EventStatus
|
Status EventStatus
|
||||||
|
TotalOddOutcomes int64
|
||||||
IsMonitored bool
|
IsMonitored bool
|
||||||
DefaultIsFeatured bool
|
DefaultIsFeatured bool
|
||||||
DefaultIsActive bool
|
DefaultIsActive bool
|
||||||
|
|
@ -149,6 +150,7 @@ type BaseEventRes struct {
|
||||||
StartTime time.Time `json:"start_time"`
|
StartTime time.Time `json:"start_time"`
|
||||||
Source EventSource `json:"source"`
|
Source EventSource `json:"source"`
|
||||||
Status EventStatus `json:"status"`
|
Status EventStatus `json:"status"`
|
||||||
|
TotalOddOutcomes int64 `json:"total_odd_outcomes"`
|
||||||
IsMonitored bool `json:"is_monitored"`
|
IsMonitored bool `json:"is_monitored"`
|
||||||
DefaultIsFeatured bool `json:"default_is_featured"`
|
DefaultIsFeatured bool `json:"default_is_featured"`
|
||||||
DefaultIsActive bool `json:"default_is_active"`
|
DefaultIsActive bool `json:"default_is_active"`
|
||||||
|
|
@ -178,6 +180,7 @@ type EventWithSettings struct {
|
||||||
StartTime time.Time
|
StartTime time.Time
|
||||||
Source EventSource
|
Source EventSource
|
||||||
Status EventStatus
|
Status EventStatus
|
||||||
|
TotalOddOutcomes int64
|
||||||
IsMonitored bool
|
IsMonitored bool
|
||||||
IsFeatured bool
|
IsFeatured bool
|
||||||
IsActive bool
|
IsActive bool
|
||||||
|
|
@ -231,6 +234,7 @@ type EventWithSettingsRes struct {
|
||||||
StartTime time.Time `json:"start_time"`
|
StartTime time.Time `json:"start_time"`
|
||||||
Source EventSource `json:"source"`
|
Source EventSource `json:"source"`
|
||||||
Status EventStatus `json:"status"`
|
Status EventStatus `json:"status"`
|
||||||
|
TotalOddOutcomes int64 `json:"total_odd_outcomes"`
|
||||||
IsMonitored bool `json:"is_monitored"`
|
IsMonitored bool `json:"is_monitored"`
|
||||||
IsFeatured bool `json:"is_featured"`
|
IsFeatured bool `json:"is_featured"`
|
||||||
IsActive bool `json:"is_active"`
|
IsActive bool `json:"is_active"`
|
||||||
|
|
@ -332,6 +336,7 @@ func ConvertDBEvent(event dbgen.EventWithCountry) BaseEvent {
|
||||||
StartTime: event.StartTime.Time.UTC(),
|
StartTime: event.StartTime.Time.UTC(),
|
||||||
Source: EventSource(event.Source),
|
Source: EventSource(event.Source),
|
||||||
Status: EventStatus(event.Status),
|
Status: EventStatus(event.Status),
|
||||||
|
TotalOddOutcomes: event.TotalOutcomes,
|
||||||
DefaultIsFeatured: event.DefaultIsFeatured,
|
DefaultIsFeatured: event.DefaultIsFeatured,
|
||||||
IsMonitored: event.IsMonitored,
|
IsMonitored: event.IsMonitored,
|
||||||
DefaultIsActive: event.DefaultIsActive,
|
DefaultIsActive: event.DefaultIsActive,
|
||||||
|
|
@ -422,6 +427,7 @@ func ConvertDBEventWithSetting(event dbgen.EventWithSetting) EventWithSettings {
|
||||||
StartTime: event.StartTime.Time.UTC(),
|
StartTime: event.StartTime.Time.UTC(),
|
||||||
Source: EventSource(event.Source),
|
Source: EventSource(event.Source),
|
||||||
Status: EventStatus(event.Status),
|
Status: EventStatus(event.Status),
|
||||||
|
TotalOddOutcomes: event.TotalOutcomes,
|
||||||
IsFeatured: event.IsFeatured,
|
IsFeatured: event.IsFeatured,
|
||||||
IsMonitored: event.IsMonitored,
|
IsMonitored: event.IsMonitored,
|
||||||
IsActive: event.IsActive,
|
IsActive: event.IsActive,
|
||||||
|
|
@ -498,6 +504,7 @@ func ConvertEventRes(event BaseEvent) BaseEventRes {
|
||||||
StartTime: event.StartTime.UTC(),
|
StartTime: event.StartTime.UTC(),
|
||||||
Source: EventSource(event.Source),
|
Source: EventSource(event.Source),
|
||||||
Status: EventStatus(event.Status),
|
Status: EventStatus(event.Status),
|
||||||
|
TotalOddOutcomes: event.TotalOddOutcomes,
|
||||||
DefaultIsFeatured: event.DefaultIsFeatured,
|
DefaultIsFeatured: event.DefaultIsFeatured,
|
||||||
IsMonitored: event.IsMonitored,
|
IsMonitored: event.IsMonitored,
|
||||||
DefaultIsActive: event.DefaultIsActive,
|
DefaultIsActive: event.DefaultIsActive,
|
||||||
|
|
@ -537,6 +544,7 @@ func ConvertEventWitSettingRes(event EventWithSettings) EventWithSettingsRes {
|
||||||
StartTime: event.StartTime.UTC(),
|
StartTime: event.StartTime.UTC(),
|
||||||
Source: EventSource(event.Source),
|
Source: EventSource(event.Source),
|
||||||
Status: EventStatus(event.Status),
|
Status: EventStatus(event.Status),
|
||||||
|
TotalOddOutcomes: event.TotalOddOutcomes,
|
||||||
IsFeatured: event.IsFeatured,
|
IsFeatured: event.IsFeatured,
|
||||||
IsMonitored: event.IsMonitored,
|
IsMonitored: event.IsMonitored,
|
||||||
IsActive: event.IsActive,
|
IsActive: event.IsActive,
|
||||||
|
|
|
||||||
|
|
@ -9,42 +9,45 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreateOddMarket struct {
|
type CreateOddMarket struct {
|
||||||
EventID int64
|
EventID int64
|
||||||
MarketCategory string
|
MarketCategory string
|
||||||
MarketType string
|
MarketType string
|
||||||
MarketName string
|
MarketName string
|
||||||
MarketID int64
|
MarketID int64
|
||||||
UpdatedAt time.Time
|
NumberOfOutcomes int64
|
||||||
Odds []map[string]interface{}
|
UpdatedAt time.Time
|
||||||
|
Odds []map[string]interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type OddMarket struct {
|
type OddMarket struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
EventID int64 `json:"event_id"`
|
EventID int64 `json:"event_id"`
|
||||||
MarketType string `json:"market_type"`
|
MarketType string `json:"market_type"`
|
||||||
MarketName string `json:"market_name"`
|
MarketName string `json:"market_name"`
|
||||||
MarketCategory string `json:"market_category"`
|
MarketCategory string `json:"market_category"`
|
||||||
MarketID int64 `json:"market_id"`
|
MarketID int64 `json:"market_id"`
|
||||||
RawOdds []json.RawMessage `json:"raw_odds"`
|
NumberOfOutcomes int64 `json:"number_of_outcomes"`
|
||||||
FetchedAt time.Time `json:"fetched_at"`
|
RawOdds []json.RawMessage `json:"raw_odds"`
|
||||||
ExpiresAt time.Time `json:"expires_at"`
|
FetchedAt time.Time `json:"fetched_at"`
|
||||||
DefaultIsActive bool `json:"is_active"`
|
ExpiresAt time.Time `json:"expires_at"`
|
||||||
IsMonitored bool `json:"is_monitored"`
|
DefaultIsActive bool `json:"is_active"`
|
||||||
IsLive bool `json:"is_live"`
|
IsMonitored bool `json:"is_monitored"`
|
||||||
Status EventStatus `json:"status"`
|
IsLive bool `json:"is_live"`
|
||||||
Source EventSource `json:"source"`
|
Status EventStatus `json:"status"`
|
||||||
|
Source EventSource `json:"source"`
|
||||||
}
|
}
|
||||||
type OddMarketWithSettings struct {
|
type OddMarketWithSettings struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
EventID int64 `json:"event_id"`
|
EventID int64 `json:"event_id"`
|
||||||
MarketType string `json:"market_type"`
|
MarketType string `json:"market_type"`
|
||||||
MarketName string `json:"market_name"`
|
MarketName string `json:"market_name"`
|
||||||
MarketCategory string `json:"market_category"`
|
MarketCategory string `json:"market_category"`
|
||||||
MarketID int64 `json:"market_id"`
|
MarketID int64 `json:"market_id"`
|
||||||
RawOdds []json.RawMessage `json:"raw_odds"`
|
NumberOfOutcomes int64 `json:"number_of_outcomes"`
|
||||||
FetchedAt time.Time `json:"fetched_at"`
|
RawOdds []json.RawMessage `json:"raw_odds"`
|
||||||
ExpiresAt time.Time `json:"expires_at"`
|
FetchedAt time.Time `json:"fetched_at"`
|
||||||
IsActive bool `json:"is_active"`
|
ExpiresAt time.Time `json:"expires_at"`
|
||||||
|
IsActive bool `json:"is_active"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type OddMarketSettings struct {
|
type OddMarketSettings struct {
|
||||||
|
|
@ -78,8 +81,8 @@ type CreateOddMarketSettingsReq struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateGlobalOddMarketSettingsReq struct {
|
type UpdateGlobalOddMarketSettingsReq struct {
|
||||||
OddMarketID int64 `json:"odd_market_id"`
|
OddMarketID int64 `json:"odd_market_id"`
|
||||||
IsActive *bool `json:"is_active,omitempty"`
|
IsActive *bool `json:"is_active,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RawOddsByMarketID struct {
|
type RawOddsByMarketID struct {
|
||||||
|
|
@ -112,20 +115,21 @@ func ConvertDBOddMarket(oddMarket dbgen.OddsMarketWithEvent) (OddMarket, error)
|
||||||
rawOdds = []json.RawMessage{} // explicit empty slice
|
rawOdds = []json.RawMessage{} // explicit empty slice
|
||||||
}
|
}
|
||||||
return OddMarket{
|
return OddMarket{
|
||||||
ID: oddMarket.ID,
|
ID: oddMarket.ID,
|
||||||
EventID: oddMarket.EventID,
|
EventID: oddMarket.EventID,
|
||||||
MarketType: oddMarket.MarketType,
|
MarketType: oddMarket.MarketType,
|
||||||
MarketName: oddMarket.MarketName,
|
MarketName: oddMarket.MarketName,
|
||||||
MarketCategory: oddMarket.MarketCategory,
|
MarketCategory: oddMarket.MarketCategory,
|
||||||
MarketID: oddMarket.MarketID,
|
MarketID: oddMarket.MarketID,
|
||||||
RawOdds: rawOdds,
|
NumberOfOutcomes: oddMarket.NumberOfOutcomes,
|
||||||
FetchedAt: oddMarket.FetchedAt.Time,
|
RawOdds: rawOdds,
|
||||||
ExpiresAt: oddMarket.ExpiresAt.Time,
|
FetchedAt: oddMarket.FetchedAt.Time,
|
||||||
DefaultIsActive: oddMarket.DefaultIsActive,
|
ExpiresAt: oddMarket.ExpiresAt.Time,
|
||||||
IsMonitored: oddMarket.IsMonitored,
|
DefaultIsActive: oddMarket.DefaultIsActive,
|
||||||
IsLive: oddMarket.IsLive,
|
IsMonitored: oddMarket.IsMonitored,
|
||||||
Status: EventStatus(oddMarket.Status),
|
IsLive: oddMarket.IsLive,
|
||||||
Source: EventSource(oddMarket.Source),
|
Status: EventStatus(oddMarket.Status),
|
||||||
|
Source: EventSource(oddMarket.Source),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,14 +152,15 @@ func ConvertCreateOddMarket(oddMarket CreateOddMarket) (dbgen.InsertOddsMarketPa
|
||||||
}
|
}
|
||||||
|
|
||||||
return dbgen.InsertOddsMarketParams{
|
return dbgen.InsertOddsMarketParams{
|
||||||
EventID: oddMarket.EventID,
|
EventID: oddMarket.EventID,
|
||||||
MarketType: oddMarket.MarketType,
|
MarketType: oddMarket.MarketType,
|
||||||
MarketName: oddMarket.MarketName,
|
MarketName: oddMarket.MarketName,
|
||||||
MarketCategory: oddMarket.MarketCategory,
|
MarketCategory: oddMarket.MarketCategory,
|
||||||
MarketID: oddMarket.MarketID,
|
MarketID: oddMarket.MarketID,
|
||||||
RawOdds: rawOddsBytes,
|
NumberOfOutcomes: oddMarket.NumberOfOutcomes,
|
||||||
FetchedAt: pgtype.Timestamp{Time: time.Now(), Valid: true},
|
RawOdds: rawOddsBytes,
|
||||||
ExpiresAt: pgtype.Timestamp{Time: (time.Now()).Add(time.Hour), Valid: true},
|
FetchedAt: pgtype.Timestamp{Time: time.Now(), Valid: true},
|
||||||
|
ExpiresAt: pgtype.Timestamp{Time: (time.Now()).Add(time.Hour), Valid: true},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -182,16 +187,17 @@ func ConvertDBOddMarketWithSetting(oms dbgen.OddsMarketWithSetting) (OddMarketWi
|
||||||
rawOdds = []json.RawMessage{} // explicit empty slice
|
rawOdds = []json.RawMessage{} // explicit empty slice
|
||||||
}
|
}
|
||||||
return OddMarketWithSettings{
|
return OddMarketWithSettings{
|
||||||
ID: oms.ID,
|
ID: oms.ID,
|
||||||
EventID: oms.EventID,
|
EventID: oms.EventID,
|
||||||
MarketType: oms.MarketType,
|
MarketType: oms.MarketType,
|
||||||
MarketName: oms.MarketName,
|
MarketName: oms.MarketName,
|
||||||
MarketCategory: oms.MarketCategory,
|
MarketCategory: oms.MarketCategory,
|
||||||
MarketID: oms.MarketID,
|
MarketID: oms.MarketID,
|
||||||
RawOdds: rawOdds,
|
NumberOfOutcomes: oms.NumberOfOutcomes,
|
||||||
FetchedAt: oms.FetchedAt.Time,
|
RawOdds: rawOdds,
|
||||||
ExpiresAt: oms.ExpiresAt.Time,
|
FetchedAt: oms.FetchedAt.Time,
|
||||||
IsActive: oms.IsActive,
|
ExpiresAt: oms.ExpiresAt.Time,
|
||||||
|
IsActive: oms.IsActive,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,9 @@ func (s *Store) GetEventsWithSettings(ctx context.Context, companyID int64, filt
|
||||||
StartTime: event.StartTime.Time.UTC(),
|
StartTime: event.StartTime.Time.UTC(),
|
||||||
Source: domain.EventSource(event.Source),
|
Source: domain.EventSource(event.Source),
|
||||||
Status: domain.EventStatus(event.Status),
|
Status: domain.EventStatus(event.Status),
|
||||||
|
TotalOddOutcomes: event.TotalOutcomes,
|
||||||
|
SourceEventID: event.SourceEventID,
|
||||||
|
WinningUpperLimit: event.WinningUpperLimit,
|
||||||
IsFeatured: event.IsFeatured,
|
IsFeatured: event.IsFeatured,
|
||||||
IsMonitored: event.IsMonitored,
|
IsMonitored: event.IsMonitored,
|
||||||
IsActive: event.IsActive,
|
IsActive: event.IsActive,
|
||||||
|
|
@ -207,6 +210,9 @@ func (s *Store) GetEventWithSettingByID(ctx context.Context, ID int64, companyID
|
||||||
StartTime: event.StartTime.Time.UTC(),
|
StartTime: event.StartTime.Time.UTC(),
|
||||||
Source: domain.EventSource(event.Source),
|
Source: domain.EventSource(event.Source),
|
||||||
Status: domain.EventStatus(event.Status),
|
Status: domain.EventStatus(event.Status),
|
||||||
|
TotalOddOutcomes: event.TotalOutcomes,
|
||||||
|
SourceEventID: event.SourceEventID,
|
||||||
|
WinningUpperLimit: event.WinningUpperLimit,
|
||||||
IsFeatured: event.IsFeatured,
|
IsFeatured: event.IsFeatured,
|
||||||
IsMonitored: event.IsMonitored,
|
IsMonitored: event.IsMonitored,
|
||||||
IsActive: event.IsActive,
|
IsActive: event.IsActive,
|
||||||
|
|
|
||||||
|
|
@ -180,16 +180,17 @@ func (s *Store) GetOddsWithSettingsByMarketID(ctx context.Context, marketID int6
|
||||||
}
|
}
|
||||||
|
|
||||||
converted := domain.OddMarketWithSettings{
|
converted := domain.OddMarketWithSettings{
|
||||||
ID: odds.ID,
|
ID: odds.ID,
|
||||||
EventID: odds.EventID,
|
EventID: odds.EventID,
|
||||||
MarketType: odds.MarketType,
|
MarketType: odds.MarketType,
|
||||||
MarketName: odds.MarketName,
|
MarketName: odds.MarketName,
|
||||||
MarketCategory: odds.MarketCategory,
|
MarketCategory: odds.MarketCategory,
|
||||||
MarketID: odds.MarketID,
|
MarketID: odds.MarketID,
|
||||||
RawOdds: rawOdds,
|
NumberOfOutcomes: odds.NumberOfOutcomes,
|
||||||
FetchedAt: odds.FetchedAt.Time,
|
RawOdds: rawOdds,
|
||||||
ExpiresAt: odds.ExpiresAt.Time,
|
FetchedAt: odds.FetchedAt.Time,
|
||||||
IsActive: odds.IsActive,
|
ExpiresAt: odds.ExpiresAt.Time,
|
||||||
|
IsActive: odds.IsActive,
|
||||||
}
|
}
|
||||||
return converted, nil
|
return converted, nil
|
||||||
}
|
}
|
||||||
|
|
@ -221,16 +222,17 @@ func (s *Store) GetOddsWithSettingsByID(ctx context.Context, ID int64, companyID
|
||||||
}
|
}
|
||||||
|
|
||||||
converted := domain.OddMarketWithSettings{
|
converted := domain.OddMarketWithSettings{
|
||||||
ID: odds.ID,
|
ID: odds.ID,
|
||||||
EventID: odds.EventID,
|
EventID: odds.EventID,
|
||||||
MarketType: odds.MarketType,
|
MarketType: odds.MarketType,
|
||||||
MarketName: odds.MarketName,
|
MarketName: odds.MarketName,
|
||||||
MarketCategory: odds.MarketCategory,
|
MarketCategory: odds.MarketCategory,
|
||||||
MarketID: odds.MarketID,
|
MarketID: odds.MarketID,
|
||||||
RawOdds: rawOdds,
|
NumberOfOutcomes: odds.NumberOfOutcomes,
|
||||||
FetchedAt: odds.FetchedAt.Time,
|
RawOdds: rawOdds,
|
||||||
ExpiresAt: odds.ExpiresAt.Time,
|
FetchedAt: odds.FetchedAt.Time,
|
||||||
IsActive: odds.IsActive,
|
ExpiresAt: odds.ExpiresAt.Time,
|
||||||
|
IsActive: odds.IsActive,
|
||||||
}
|
}
|
||||||
|
|
||||||
return converted, nil
|
return converted, nil
|
||||||
|
|
@ -287,16 +289,17 @@ func (s *Store) GetOddsWithSettingsByEventID(ctx context.Context, eventID int64,
|
||||||
}
|
}
|
||||||
|
|
||||||
result[i] = domain.OddMarketWithSettings{
|
result[i] = domain.OddMarketWithSettings{
|
||||||
ID: o.ID,
|
ID: o.ID,
|
||||||
EventID: o.EventID,
|
EventID: o.EventID,
|
||||||
MarketType: o.MarketType,
|
MarketType: o.MarketType,
|
||||||
MarketName: o.MarketName,
|
MarketName: o.MarketName,
|
||||||
MarketCategory: o.MarketCategory,
|
MarketCategory: o.MarketCategory,
|
||||||
MarketID: o.MarketID,
|
MarketID: o.MarketID,
|
||||||
RawOdds: rawOdds,
|
NumberOfOutcomes: o.NumberOfOutcomes,
|
||||||
FetchedAt: o.FetchedAt.Time,
|
RawOdds: rawOdds,
|
||||||
ExpiresAt: o.ExpiresAt.Time,
|
FetchedAt: o.FetchedAt.Time,
|
||||||
IsActive: o.IsActive,
|
ExpiresAt: o.ExpiresAt.Time,
|
||||||
|
IsActive: o.IsActive,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1236,8 +1236,6 @@ func (s *Service) ProcessBetCashback(ctx context.Context) error {
|
||||||
zap.Int64("userID", bet.UserID),
|
zap.Int64("userID", bet.UserID),
|
||||||
zap.Error(err))
|
zap.Error(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a notification here
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -557,13 +557,14 @@ func (s *ServiceImpl) storeSection(ctx context.Context, eventID int64, fi, secti
|
||||||
}
|
}
|
||||||
|
|
||||||
marketRecord := domain.CreateOddMarket{
|
marketRecord := domain.CreateOddMarket{
|
||||||
EventID: eventID,
|
EventID: eventID,
|
||||||
MarketCategory: sectionName,
|
MarketCategory: sectionName,
|
||||||
MarketType: marketType,
|
MarketType: marketType,
|
||||||
MarketName: market.Name,
|
MarketName: market.Name,
|
||||||
MarketID: marketIDint,
|
MarketID: marketIDint,
|
||||||
UpdatedAt: updatedAt,
|
NumberOfOutcomes: int64(len(market.Odds)),
|
||||||
Odds: marketOdds,
|
UpdatedAt: updatedAt,
|
||||||
|
Odds: marketOdds,
|
||||||
// bwin won't reach this code so bet365 is hardcoded for now
|
// bwin won't reach this code so bet365 is hardcoded for now
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -676,8 +677,8 @@ func (s *ServiceImpl) SaveOddsSetting(ctx context.Context, odd domain.CreateOddM
|
||||||
return s.store.SaveOddsSetting(ctx, odd)
|
return s.store.SaveOddsSetting(ctx, odd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ServiceImpl) UpdateGlobalOddsSetting(ctx context.Context, odd domain.UpdateGlobalOddMarketSettings) error {
|
func (s *ServiceImpl) UpdateGlobalOddsSetting(ctx context.Context, odd domain.UpdateGlobalOddMarketSettings) error {
|
||||||
return s.store.UpdateGlobalOddsSetting(ctx, odd);
|
return s.store.UpdateGlobalOddsSetting(ctx, odd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ServiceImpl) SaveOddsSettingReq(ctx context.Context, companyID int64, req domain.CreateOddMarketSettingsReq) error {
|
func (s *ServiceImpl) SaveOddsSettingReq(ctx context.Context, companyID int64, req domain.CreateOddMarketSettingsReq) error {
|
||||||
|
|
@ -749,7 +750,7 @@ func (s *ServiceImpl) DeleteAllCompanyOddsSetting(ctx context.Context, companyID
|
||||||
return s.store.DeleteAllCompanyOddsSetting(ctx, companyID)
|
return s.store.DeleteAllCompanyOddsSetting(ctx, companyID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ServiceImpl) DeleteCompanyOddsSettingByOddMarketID(ctx context.Context, companyID int64, oddMarketID int64) error{
|
func (s *ServiceImpl) DeleteCompanyOddsSettingByOddMarketID(ctx context.Context, companyID int64, oddMarketID int64) error {
|
||||||
return s.store.DeleteCompanyOddsSettingByOddMarketID(ctx, companyID, oddMarketID)
|
return s.store.DeleteCompanyOddsSettingByOddMarketID(ctx, companyID, oddMarketID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -262,7 +262,6 @@ func (s *Service) FetchB365ResultAndUpdateBets(ctx context.Context) error {
|
||||||
eventLogger := s.mongoLogger.With(
|
eventLogger := s.mongoLogger.With(
|
||||||
zap.Int64("eventID", event.ID),
|
zap.Int64("eventID", event.ID),
|
||||||
)
|
)
|
||||||
|
|
||||||
result, err := s.FetchB365Result(ctx, event.SourceEventID)
|
result, err := s.FetchB365Result(ctx, event.SourceEventID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == ErrEventIsNotActive {
|
if err == ErrEventIsNotActive {
|
||||||
|
|
@ -457,7 +456,6 @@ func (s *Service) FetchB365ResultAndUpdateBets(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (s *Service) CheckAndUpdateExpiredB365Events(ctx context.Context) (int64, error) {
|
func (s *Service) CheckAndUpdateExpiredB365Events(ctx context.Context) (int64, error) {
|
||||||
events, _, err := s.repo.GetAllEvents(ctx, domain.EventFilter{
|
events, _, err := s.repo.GetAllEvents(ctx, domain.EventFilter{
|
||||||
LastStartTime: domain.ValidTime{
|
LastStartTime: domain.ValidTime{
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ func StartDataFetchingCrons(eventService eventsvc.Service, oddsService oddssvc.S
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, job := range schedule {
|
for _, job := range schedule {
|
||||||
// job.task()
|
job.task()
|
||||||
if _, err := c.AddFunc(job.spec, job.task); err != nil {
|
if _, err := c.AddFunc(job.spec, job.task); err != nil {
|
||||||
mongoLogger.Error("Failed to schedule data fetching cron job",
|
mongoLogger.Error("Failed to schedule data fetching cron job",
|
||||||
zap.Error(err),
|
zap.Error(err),
|
||||||
|
|
|
||||||
|
|
@ -227,11 +227,8 @@ func (h *Handler) GetAllCashiers(c *fiber.Ctx) error {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, errMsg)
|
return fiber.NewError(fiber.StatusBadRequest, errMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
cashiers, total, err := h.userSvc.GetAllCashiers(c.Context(), domain.UserFilter{
|
cashiers, total, err := h.userSvc.GetAllCashiers(c.Context(), filter)
|
||||||
Query: searchString,
|
|
||||||
CreatedBefore: createdBefore,
|
|
||||||
CreatedAfter: createdAfter,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.mongoLoggerSvc.Error("failed to get all cashiers",
|
h.mongoLoggerSvc.Error("failed to get all cashiers",
|
||||||
zap.Int("status_code", fiber.StatusInternalServerError),
|
zap.Int("status_code", fiber.StatusInternalServerError),
|
||||||
|
|
|
||||||
|
|
@ -285,6 +285,11 @@ func (h *Handler) GetTenantUpcomingEvents(c *fiber.Ctx) error {
|
||||||
Value: firstStartTimeParsed,
|
Value: firstStartTimeParsed,
|
||||||
Valid: true,
|
Valid: true,
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
firstStartTime = domain.ValidTime{
|
||||||
|
Value: time.Now(),
|
||||||
|
Valid: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lastStartTimeQuery := c.Query("last_start_time")
|
lastStartTimeQuery := c.Query("last_start_time")
|
||||||
|
|
|
||||||
14
makefile
14
makefile
|
|
@ -69,6 +69,20 @@ seed_data:
|
||||||
echo "Seeding $$file..."; \
|
echo "Seeding $$file..."; \
|
||||||
cat $$file | docker exec -i fortunebet-backend-postgres-1 psql -U root -d gh; \
|
cat $$file | docker exec -i fortunebet-backend-postgres-1 psql -U root -d gh; \
|
||||||
done
|
done
|
||||||
|
.PHONY: seed_dev_data
|
||||||
|
seed_dev_data:
|
||||||
|
@echo "Waiting for PostgreSQL to be ready..."
|
||||||
|
@until docker exec fortunebet-backend-postgres-1 pg_isready -U root -d gh; do \
|
||||||
|
echo "PostgreSQL is not ready yet..."; \
|
||||||
|
sleep 1; \
|
||||||
|
done
|
||||||
|
cat db/scripts/fix_autoincrement_desync.sql | docker exec -i fortunebet-backend-postgres-1 psql -U root -d gh;
|
||||||
|
@for file in db/dev_data/*.sql; do \
|
||||||
|
if [ -f "$$file" ]; then \
|
||||||
|
echo "Seeding $$file..."; \
|
||||||
|
cat $$file | docker exec -i fortunebet-backend-postgres-1 psql -U root -d gh; \
|
||||||
|
fi \
|
||||||
|
done
|
||||||
postgres_log:
|
postgres_log:
|
||||||
docker logs fortunebet-backend-postgres-1
|
docker logs fortunebet-backend-postgres-1
|
||||||
.PHONY: swagger
|
.PHONY: swagger
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user