Enetpulse fixes
This commit is contained in:
parent
af7c792dee
commit
9cb008225b
|
|
@ -1,2 +0,0 @@
|
||||||
DROP TABLE IF EXISTS enetpulse_sports;
|
|
||||||
DROP TABLE IF EXISTS enetpulse_tournament_templates;
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
CREATE TABLE IF NOT EXISTS enetpulse_sports (
|
|
||||||
id BIGSERIAL PRIMARY KEY,
|
|
||||||
sport_id VARCHAR(50) NOT NULL UNIQUE, -- from API "id"
|
|
||||||
name VARCHAR(255) NOT NULL, -- from API "name"
|
|
||||||
updates_count INT DEFAULT 0, -- from API "n"
|
|
||||||
last_updated_at TIMESTAMPTZ, -- from API "ut"
|
|
||||||
status INT DEFAULT 1, -- optional status (active/inactive)
|
|
||||||
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
updated_at TIMESTAMPTZ
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS enetpulse_tournament_templates (
|
|
||||||
id BIGSERIAL PRIMARY KEY,
|
|
||||||
template_id VARCHAR(50) NOT NULL UNIQUE, -- from API "id"
|
|
||||||
name VARCHAR(255) NOT NULL, -- from API "name"
|
|
||||||
sport_fk VARCHAR(50) NOT NULL REFERENCES enetpulse_sports(sport_id) ON DELETE CASCADE,
|
|
||||||
gender VARCHAR(20) DEFAULT 'unknown', -- from API "gender" {male, female, mixed, unknown}
|
|
||||||
updates_count INT DEFAULT 0, -- from API "n"
|
|
||||||
last_updated_at TIMESTAMPTZ, -- from API "ut"
|
|
||||||
status INT DEFAULT 1, -- optional status (active/inactive)
|
|
||||||
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
updated_at TIMESTAMPTZ
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS enetpulse_tournaments (
|
|
||||||
id BIGSERIAL PRIMARY KEY,
|
|
||||||
tournament_id VARCHAR(50) NOT NULL UNIQUE, -- from API "id"
|
|
||||||
name VARCHAR(255) NOT NULL, -- from API "name"
|
|
||||||
|
|
||||||
-- Link to the template it belongs to:
|
|
||||||
tournament_template_fk VARCHAR(50) NOT NULL
|
|
||||||
REFERENCES enetpulse_tournament_templates(template_id) ON DELETE CASCADE,
|
|
||||||
|
|
||||||
updates_count INT DEFAULT 0, -- from API "n"
|
|
||||||
last_updated_at TIMESTAMPTZ, -- from API "ut"
|
|
||||||
status INT DEFAULT 1, -- optional active/inactive flag
|
|
||||||
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
updated_at TIMESTAMPTZ
|
|
||||||
);
|
|
||||||
|
|
||||||
-- Create table for tournament stages
|
|
||||||
CREATE TABLE IF NOT EXISTS enetpulse_tournament_stages (
|
|
||||||
id BIGSERIAL PRIMARY KEY,
|
|
||||||
stage_id VARCHAR(50) NOT NULL UNIQUE, -- from API "id"
|
|
||||||
name VARCHAR(255) NOT NULL, -- from API "name"
|
|
||||||
tournament_fk VARCHAR(50) NOT NULL REFERENCES enetpulse_tournaments(tournament_id) ON DELETE CASCADE,
|
|
||||||
-- from API "tournamentFK"
|
|
||||||
gender VARCHAR(20) DEFAULT 'unknown', -- from API "gender" {male, female, mixed, unknown}
|
|
||||||
country_fk VARCHAR(50), -- from API "countryFK"
|
|
||||||
country_name VARCHAR(255), -- from API "country_name"
|
|
||||||
start_date TIMESTAMPTZ, -- from API "startdate"
|
|
||||||
end_date TIMESTAMPTZ, -- from API "enddate"
|
|
||||||
updates_count INT DEFAULT 0, -- from API "n"
|
|
||||||
last_updated_at TIMESTAMPTZ, -- from API "ut"
|
|
||||||
status INT DEFAULT 1, -- optional status (active/inactive)
|
|
||||||
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
updated_at TIMESTAMPTZ
|
|
||||||
);
|
|
||||||
|
|
||||||
-- Index to quickly query by tournament_fk
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_enetpulse_tournament_stages_tournament_fk
|
|
||||||
ON enetpulse_tournament_stages (tournament_fk);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,2 +1,5 @@
|
||||||
DROP TABLE IF EXISTS enetpulse_sports;
|
DROP TABLE IF EXISTS enetpulse_sports;
|
||||||
DROP TABLE IF EXISTS enetpulse_tournament_templates;
|
DROP TABLE IF EXISTS enetpulse_tournament_templates;
|
||||||
|
DROP TABLE IF EXISTS enetpulse_tournaments;
|
||||||
|
DROP TABLE IF EXISTS enetpulse_tournament_stages;
|
||||||
|
DROP TABLE IF EXISTS enetpulse_fixtures;
|
||||||
|
|
@ -21,3 +21,207 @@ CREATE TABLE IF NOT EXISTS enetpulse_tournament_templates (
|
||||||
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
updated_at TIMESTAMPTZ
|
updated_at TIMESTAMPTZ
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS enetpulse_tournaments (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
tournament_id VARCHAR(50) NOT NULL UNIQUE, -- from API "id"
|
||||||
|
name VARCHAR(255) NOT NULL, -- from API "name"
|
||||||
|
|
||||||
|
-- Link to the template it belongs to:
|
||||||
|
tournament_template_fk VARCHAR(50) NOT NULL
|
||||||
|
REFERENCES enetpulse_tournament_templates(template_id) ON DELETE CASCADE,
|
||||||
|
|
||||||
|
updates_count INT DEFAULT 0, -- from API "n"
|
||||||
|
last_updated_at TIMESTAMPTZ, -- from API "ut"
|
||||||
|
status INT DEFAULT 1, -- optional active/inactive flag
|
||||||
|
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMPTZ
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS enetpulse_tournament_stages (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
stage_id VARCHAR(50) NOT NULL UNIQUE, -- from API "id"
|
||||||
|
name VARCHAR(255) NOT NULL, -- from API "name"
|
||||||
|
tournament_fk VARCHAR(50) NOT NULL REFERENCES enetpulse_tournaments(tournament_id) ON DELETE CASCADE,
|
||||||
|
-- from API "tournamentFK"
|
||||||
|
gender VARCHAR(20) DEFAULT 'unknown', -- from API "gender" {male, female, mixed, unknown}
|
||||||
|
country_fk VARCHAR(50), -- from API "countryFK"
|
||||||
|
country_name VARCHAR(255), -- from API "country_name"
|
||||||
|
start_date TIMESTAMPTZ, -- from API "startdate"
|
||||||
|
end_date TIMESTAMPTZ, -- from API "enddate"
|
||||||
|
updates_count INT DEFAULT 0, -- from API "n"
|
||||||
|
last_updated_at TIMESTAMPTZ, -- from API "ut"
|
||||||
|
status INT DEFAULT 1, -- optional status (active/inactive)
|
||||||
|
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMPTZ
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_enetpulse_tournament_stages_tournament_fk
|
||||||
|
ON enetpulse_tournament_stages (tournament_fk);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS enetpulse_fixtures (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
fixture_id VARCHAR(50) NOT NULL UNIQUE, -- from API "id"
|
||||||
|
name VARCHAR(255) NOT NULL, -- fixture name (e.g. 12 de Junio-Sol de America)
|
||||||
|
|
||||||
|
sport_fk VARCHAR(50) NOT NULL REFERENCES enetpulse_sports(sport_id) ON DELETE CASCADE,
|
||||||
|
tournament_fk VARCHAR(50), -- raw tournamentFK (optional)
|
||||||
|
tournament_template_fk VARCHAR(50) REFERENCES enetpulse_tournament_templates(template_id) ON DELETE CASCADE,
|
||||||
|
tournament_stage_fk VARCHAR(50) REFERENCES enetpulse_tournament_stages(stage_id) ON DELETE CASCADE,
|
||||||
|
|
||||||
|
tournament_stage_name VARCHAR(255),
|
||||||
|
tournament_name VARCHAR(255),
|
||||||
|
tournament_template_name VARCHAR(255),
|
||||||
|
sport_name VARCHAR(255),
|
||||||
|
gender VARCHAR(20),
|
||||||
|
|
||||||
|
start_date TIMESTAMPTZ NOT NULL, -- startdate
|
||||||
|
status_type VARCHAR(50), -- Not started, Live, Finished
|
||||||
|
status_desc_fk VARCHAR(50), -- status_descFK
|
||||||
|
round_type_fk VARCHAR(50), -- round_typeFK
|
||||||
|
updates_count INT DEFAULT 0, -- n
|
||||||
|
last_updated_at TIMESTAMPTZ, -- ut
|
||||||
|
|
||||||
|
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMPTZ
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS enetpulse_results (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
result_id VARCHAR(50) NOT NULL UNIQUE, -- from API "id"
|
||||||
|
name VARCHAR(255) NOT NULL, -- event name (e.g. Brentford-Manchester City)
|
||||||
|
|
||||||
|
sport_fk VARCHAR(50) NOT NULL REFERENCES enetpulse_sports(sport_id) ON DELETE CASCADE,
|
||||||
|
tournament_fk VARCHAR(50),
|
||||||
|
tournament_template_fk VARCHAR(50) REFERENCES enetpulse_tournament_templates(template_id) ON DELETE CASCADE,
|
||||||
|
tournament_stage_fk VARCHAR(50) REFERENCES enetpulse_tournament_stages(stage_id) ON DELETE CASCADE,
|
||||||
|
|
||||||
|
tournament_stage_name VARCHAR(255),
|
||||||
|
tournament_name VARCHAR(255),
|
||||||
|
tournament_template_name VARCHAR(255),
|
||||||
|
sport_name VARCHAR(255),
|
||||||
|
|
||||||
|
start_date TIMESTAMPTZ NOT NULL, -- startdate
|
||||||
|
status_type VARCHAR(50), -- e.g. Finished
|
||||||
|
status_desc_fk VARCHAR(50), -- status_descFK
|
||||||
|
round_type_fk VARCHAR(50), -- round_typeFK
|
||||||
|
updates_count INT DEFAULT 0, -- n
|
||||||
|
last_updated_at TIMESTAMPTZ, -- ut
|
||||||
|
|
||||||
|
-- Optional metadata (dynamic but common fields are included)
|
||||||
|
round VARCHAR(50),
|
||||||
|
live VARCHAR(10),
|
||||||
|
venue_name VARCHAR(255),
|
||||||
|
livestats_plus VARCHAR(10),
|
||||||
|
livestats_type VARCHAR(50),
|
||||||
|
commentary VARCHAR(50),
|
||||||
|
lineup_confirmed BOOLEAN,
|
||||||
|
verified BOOLEAN,
|
||||||
|
spectators INT,
|
||||||
|
|
||||||
|
-- Time-related metadata
|
||||||
|
game_started TIMESTAMPTZ,
|
||||||
|
first_half_ended TIMESTAMPTZ,
|
||||||
|
second_half_started TIMESTAMPTZ,
|
||||||
|
second_half_ended TIMESTAMPTZ,
|
||||||
|
game_ended TIMESTAMPTZ,
|
||||||
|
|
||||||
|
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMPTZ
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Event Participants (teams involved in the result)
|
||||||
|
CREATE TABLE IF NOT EXISTS enetpulse_result_participants (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
participant_map_id VARCHAR(50) NOT NULL UNIQUE, -- from event_participants.*.id
|
||||||
|
result_fk VARCHAR(50) NOT NULL REFERENCES enetpulse_results(result_id) ON DELETE CASCADE,
|
||||||
|
participant_fk VARCHAR(50) NOT NULL, -- team/player FK (from API participantFK)
|
||||||
|
number INT, -- 1 or 2 (home/away indicator)
|
||||||
|
name VARCHAR(255), -- team/player name
|
||||||
|
gender VARCHAR(20),
|
||||||
|
type VARCHAR(50),
|
||||||
|
country_fk VARCHAR(50),
|
||||||
|
country_name VARCHAR(100),
|
||||||
|
|
||||||
|
-- Result details
|
||||||
|
ordinary_time VARCHAR(10),
|
||||||
|
running_score VARCHAR(10),
|
||||||
|
halftime VARCHAR(10),
|
||||||
|
final_result VARCHAR(10),
|
||||||
|
|
||||||
|
last_updated_at TIMESTAMPTZ,
|
||||||
|
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Referees / Match officials
|
||||||
|
CREATE TABLE IF NOT EXISTS enetpulse_result_referees (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
result_fk VARCHAR(50) NOT NULL REFERENCES enetpulse_results(result_id) ON DELETE CASCADE,
|
||||||
|
referee_fk VARCHAR(50),
|
||||||
|
assistant1_referee_fk VARCHAR(50),
|
||||||
|
assistant2_referee_fk VARCHAR(50),
|
||||||
|
fourth_referee_fk VARCHAR(50),
|
||||||
|
var1_referee_fk VARCHAR(50),
|
||||||
|
var2_referee_fk VARCHAR(50),
|
||||||
|
last_updated_at TIMESTAMPTZ,
|
||||||
|
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS enetpulse_outcome_types (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
outcome_type_id VARCHAR(50) NOT NULL UNIQUE, -- from API "id"
|
||||||
|
name VARCHAR(100) NOT NULL, -- e.g. "1x2"
|
||||||
|
description VARCHAR(255), -- e.g. "1x2 - 3Way"
|
||||||
|
|
||||||
|
updates_count INT DEFAULT 0, -- maps to "n"
|
||||||
|
last_updated_at TIMESTAMPTZ, -- maps to "ut"
|
||||||
|
|
||||||
|
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMPTZ
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Table for pre-match odds (main outcome entries)
|
||||||
|
CREATE TABLE IF NOT EXISTS enetpulse_preodds (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
preodds_id VARCHAR(50) NOT NULL UNIQUE, -- from API "id"
|
||||||
|
event_fk BIGINT NOT NULL, -- maps to objectFK/event
|
||||||
|
outcome_type_fk INT, -- outcome_typeFK
|
||||||
|
outcome_scope_fk INT, -- outcome_scopeFK
|
||||||
|
outcome_subtype_fk INT, -- outcome_subtypeFK
|
||||||
|
event_participant_number INT, -- event_participant_number
|
||||||
|
iparam VARCHAR(50),
|
||||||
|
iparam2 VARCHAR(50),
|
||||||
|
dparam VARCHAR(50),
|
||||||
|
dparam2 VARCHAR(50),
|
||||||
|
sparam VARCHAR(50),
|
||||||
|
|
||||||
|
updates_count INT DEFAULT 0, -- maps to "n"
|
||||||
|
last_updated_at TIMESTAMPTZ, -- maps to "ut"
|
||||||
|
|
||||||
|
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMPTZ
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Table for nested betting offers within preodds
|
||||||
|
CREATE TABLE IF NOT EXISTS enetpulse_preodds_bettingoffers (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
bettingoffer_id VARCHAR(50) NOT NULL UNIQUE, -- from API "id"
|
||||||
|
preodds_fk VARCHAR(50) NOT NULL REFERENCES enetpulse_preodds(preodds_id) ON DELETE CASCADE,
|
||||||
|
bettingoffer_status_fk INT, -- bettingoffer_statusFK
|
||||||
|
odds_provider_fk INT, -- odds_providerFK
|
||||||
|
odds NUMERIC(10,4), -- current odds
|
||||||
|
odds_old NUMERIC(10,4), -- previous odds
|
||||||
|
active BOOLEAN, -- maps "yes"/"no" to boolean
|
||||||
|
coupon_key VARCHAR(255), -- couponKey
|
||||||
|
updates_count INT DEFAULT 0, -- maps to "n"
|
||||||
|
last_updated_at TIMESTAMPTZ, -- maps to "ut"
|
||||||
|
|
||||||
|
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMPTZ
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,9 @@ SELECT
|
||||||
FROM enetpulse_tournament_templates
|
FROM enetpulse_tournament_templates
|
||||||
ORDER BY name;
|
ORDER BY name;
|
||||||
|
|
||||||
|
-- -- name: DeleteEnetpulseTournamentTemplateByID :exec
|
||||||
|
-- DELETE FROM enetpulse_tournament_templates WHERE template_id = $1;
|
||||||
|
|
||||||
-- name: CreateEnetpulseTournament :one
|
-- name: CreateEnetpulseTournament :one
|
||||||
INSERT INTO enetpulse_tournaments (
|
INSERT INTO enetpulse_tournaments (
|
||||||
tournament_id,
|
tournament_id,
|
||||||
|
|
@ -130,5 +133,243 @@ FROM enetpulse_tournament_stages
|
||||||
WHERE tournament_fk = $1
|
WHERE tournament_fk = $1
|
||||||
ORDER BY created_at DESC;
|
ORDER BY created_at DESC;
|
||||||
|
|
||||||
|
-- name: CreateEnetpulseFixture :one
|
||||||
|
INSERT INTO enetpulse_fixtures (
|
||||||
|
fixture_id,
|
||||||
|
name,
|
||||||
|
sport_fk,
|
||||||
|
tournament_fk,
|
||||||
|
tournament_template_fk,
|
||||||
|
tournament_stage_fk,
|
||||||
|
tournament_stage_name,
|
||||||
|
tournament_name,
|
||||||
|
tournament_template_name,
|
||||||
|
sport_name,
|
||||||
|
gender,
|
||||||
|
start_date,
|
||||||
|
status_type,
|
||||||
|
status_desc_fk,
|
||||||
|
round_type_fk,
|
||||||
|
updates_count,
|
||||||
|
last_updated_at,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
) VALUES (
|
||||||
|
$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP
|
||||||
|
)
|
||||||
|
ON CONFLICT (fixture_id) DO UPDATE
|
||||||
|
SET
|
||||||
|
name = EXCLUDED.name,
|
||||||
|
sport_fk = EXCLUDED.sport_fk,
|
||||||
|
tournament_fk = EXCLUDED.tournament_fk,
|
||||||
|
tournament_template_fk = EXCLUDED.tournament_template_fk,
|
||||||
|
tournament_stage_fk = EXCLUDED.tournament_stage_fk,
|
||||||
|
tournament_stage_name = EXCLUDED.tournament_stage_name,
|
||||||
|
tournament_name = EXCLUDED.tournament_name,
|
||||||
|
tournament_template_name = EXCLUDED.tournament_template_name,
|
||||||
|
sport_name = EXCLUDED.sport_name,
|
||||||
|
gender = EXCLUDED.gender,
|
||||||
|
start_date = EXCLUDED.start_date,
|
||||||
|
status_type = EXCLUDED.status_type,
|
||||||
|
status_desc_fk = EXCLUDED.status_desc_fk,
|
||||||
|
round_type_fk = EXCLUDED.round_type_fk,
|
||||||
|
updates_count = EXCLUDED.updates_count,
|
||||||
|
last_updated_at = EXCLUDED.last_updated_at,
|
||||||
|
updated_at = CURRENT_TIMESTAMP
|
||||||
|
RETURNING *;
|
||||||
|
|
||||||
|
-- name: GetAllEnetpulseFixtures :many
|
||||||
|
SELECT *
|
||||||
|
FROM enetpulse_fixtures
|
||||||
|
ORDER BY created_at DESC;
|
||||||
|
|
||||||
|
-- name: CreateEnetpulseResult :one
|
||||||
|
INSERT INTO enetpulse_results (
|
||||||
|
result_id,
|
||||||
|
name,
|
||||||
|
sport_fk,
|
||||||
|
tournament_fk,
|
||||||
|
tournament_template_fk,
|
||||||
|
tournament_stage_fk,
|
||||||
|
tournament_stage_name,
|
||||||
|
tournament_name,
|
||||||
|
tournament_template_name,
|
||||||
|
sport_name,
|
||||||
|
start_date,
|
||||||
|
status_type,
|
||||||
|
status_desc_fk,
|
||||||
|
round_type_fk,
|
||||||
|
updates_count,
|
||||||
|
last_updated_at,
|
||||||
|
round,
|
||||||
|
live,
|
||||||
|
venue_name,
|
||||||
|
livestats_plus,
|
||||||
|
livestats_type,
|
||||||
|
commentary,
|
||||||
|
lineup_confirmed,
|
||||||
|
verified,
|
||||||
|
spectators,
|
||||||
|
game_started,
|
||||||
|
first_half_ended,
|
||||||
|
second_half_started,
|
||||||
|
second_half_ended,
|
||||||
|
game_ended
|
||||||
|
) VALUES (
|
||||||
|
$1, $2, $3, $4, $5, $6,
|
||||||
|
$7, $8, $9, $10, $11,
|
||||||
|
$12, $13, $14, $15, $16,
|
||||||
|
$17, $18, $19, $20, $21,
|
||||||
|
$22, $23, $24, $25, $26,
|
||||||
|
$27, $28, $29, $30
|
||||||
|
)
|
||||||
|
ON CONFLICT (result_id) DO UPDATE
|
||||||
|
SET
|
||||||
|
name = EXCLUDED.name,
|
||||||
|
sport_fk = EXCLUDED.sport_fk,
|
||||||
|
tournament_fk = EXCLUDED.tournament_fk,
|
||||||
|
tournament_template_fk = EXCLUDED.tournament_template_fk,
|
||||||
|
tournament_stage_fk = EXCLUDED.tournament_stage_fk,
|
||||||
|
tournament_stage_name = EXCLUDED.tournament_stage_name,
|
||||||
|
tournament_name = EXCLUDED.tournament_name,
|
||||||
|
tournament_template_name = EXCLUDED.tournament_template_name,
|
||||||
|
sport_name = EXCLUDED.sport_name,
|
||||||
|
start_date = EXCLUDED.start_date,
|
||||||
|
status_type = EXCLUDED.status_type,
|
||||||
|
status_desc_fk = EXCLUDED.status_desc_fk,
|
||||||
|
round_type_fk = EXCLUDED.round_type_fk,
|
||||||
|
updates_count = EXCLUDED.updates_count,
|
||||||
|
last_updated_at = EXCLUDED.last_updated_at,
|
||||||
|
round = EXCLUDED.round,
|
||||||
|
live = EXCLUDED.live,
|
||||||
|
venue_name = EXCLUDED.venue_name,
|
||||||
|
livestats_plus = EXCLUDED.livestats_plus,
|
||||||
|
livestats_type = EXCLUDED.livestats_type,
|
||||||
|
commentary = EXCLUDED.commentary,
|
||||||
|
lineup_confirmed = EXCLUDED.lineup_confirmed,
|
||||||
|
verified = EXCLUDED.verified,
|
||||||
|
spectators = EXCLUDED.spectators,
|
||||||
|
game_started = EXCLUDED.game_started,
|
||||||
|
first_half_ended = EXCLUDED.first_half_ended,
|
||||||
|
second_half_started = EXCLUDED.second_half_started,
|
||||||
|
second_half_ended = EXCLUDED.second_half_ended,
|
||||||
|
game_ended = EXCLUDED.game_ended,
|
||||||
|
updated_at = CURRENT_TIMESTAMP
|
||||||
|
RETURNING *;
|
||||||
|
|
||||||
|
-- name: GetAllEnetpulseResults :many
|
||||||
|
SELECT *
|
||||||
|
FROM enetpulse_results
|
||||||
|
ORDER BY created_at DESC;
|
||||||
|
|
||||||
|
-- name: CreateEnetpulseOutcomeType :one
|
||||||
|
INSERT INTO enetpulse_outcome_types (
|
||||||
|
outcome_type_id,
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
updates_count,
|
||||||
|
last_updated_at,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
) VALUES (
|
||||||
|
$1, $2, $3, $4, $5, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
|
||||||
|
)
|
||||||
|
ON CONFLICT (outcome_type_id) DO UPDATE
|
||||||
|
SET
|
||||||
|
name = EXCLUDED.name,
|
||||||
|
description = EXCLUDED.description,
|
||||||
|
updates_count = EXCLUDED.updates_count,
|
||||||
|
last_updated_at = EXCLUDED.last_updated_at,
|
||||||
|
updated_at = CURRENT_TIMESTAMP
|
||||||
|
RETURNING *;
|
||||||
|
|
||||||
|
-- name: GetAllEnetpulseOutcomeTypes :many
|
||||||
|
SELECT *
|
||||||
|
FROM enetpulse_outcome_types
|
||||||
|
ORDER BY created_at DESC;
|
||||||
|
|
||||||
|
-- name: CreateEnetpulsePreodds :one
|
||||||
|
INSERT INTO enetpulse_preodds (
|
||||||
|
preodds_id,
|
||||||
|
event_fk,
|
||||||
|
outcome_type_fk,
|
||||||
|
outcome_scope_fk,
|
||||||
|
outcome_subtype_fk,
|
||||||
|
event_participant_number,
|
||||||
|
iparam,
|
||||||
|
iparam2,
|
||||||
|
dparam,
|
||||||
|
dparam2,
|
||||||
|
sparam,
|
||||||
|
updates_count,
|
||||||
|
last_updated_at,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
) VALUES (
|
||||||
|
$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP
|
||||||
|
)
|
||||||
|
ON CONFLICT (preodds_id) DO UPDATE
|
||||||
|
SET
|
||||||
|
event_fk = EXCLUDED.event_fk,
|
||||||
|
outcome_type_fk = EXCLUDED.outcome_type_fk,
|
||||||
|
outcome_scope_fk = EXCLUDED.outcome_scope_fk,
|
||||||
|
outcome_subtype_fk = EXCLUDED.outcome_subtype_fk,
|
||||||
|
event_participant_number = EXCLUDED.event_participant_number,
|
||||||
|
iparam = EXCLUDED.iparam,
|
||||||
|
iparam2 = EXCLUDED.iparam2,
|
||||||
|
dparam = EXCLUDED.dparam,
|
||||||
|
dparam2 = EXCLUDED.dparam2,
|
||||||
|
sparam = EXCLUDED.sparam,
|
||||||
|
updates_count = EXCLUDED.updates_count,
|
||||||
|
last_updated_at = EXCLUDED.last_updated_at,
|
||||||
|
updated_at = CURRENT_TIMESTAMP
|
||||||
|
RETURNING *;
|
||||||
|
|
||||||
|
-- name: GetAllEnetpulsePreodds :many
|
||||||
|
SELECT *
|
||||||
|
FROM enetpulse_preodds
|
||||||
|
ORDER BY created_at DESC;
|
||||||
|
|
||||||
|
|
||||||
|
-- name: CreateEnetpulsePreoddsBettingOffer :one
|
||||||
|
INSERT INTO enetpulse_preodds_bettingoffers (
|
||||||
|
bettingoffer_id,
|
||||||
|
preodds_fk,
|
||||||
|
bettingoffer_status_fk,
|
||||||
|
odds_provider_fk,
|
||||||
|
odds,
|
||||||
|
odds_old,
|
||||||
|
active,
|
||||||
|
coupon_key,
|
||||||
|
updates_count,
|
||||||
|
last_updated_at,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
) VALUES (
|
||||||
|
$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP
|
||||||
|
)
|
||||||
|
ON CONFLICT (bettingoffer_id) DO UPDATE
|
||||||
|
SET
|
||||||
|
preodds_fk = EXCLUDED.preodds_fk,
|
||||||
|
bettingoffer_status_fk = EXCLUDED.bettingoffer_status_fk,
|
||||||
|
odds_provider_fk = EXCLUDED.odds_provider_fk,
|
||||||
|
odds = EXCLUDED.odds,
|
||||||
|
odds_old = EXCLUDED.odds_old,
|
||||||
|
active = EXCLUDED.active,
|
||||||
|
coupon_key = EXCLUDED.coupon_key,
|
||||||
|
updates_count = EXCLUDED.updates_count,
|
||||||
|
last_updated_at = EXCLUDED.last_updated_at,
|
||||||
|
updated_at = CURRENT_TIMESTAMP
|
||||||
|
RETURNING *;
|
||||||
|
|
||||||
|
-- name: GetAllEnetpulsePreoddsBettingOffers :many
|
||||||
|
SELECT *
|
||||||
|
FROM enetpulse_preodds_bettingoffers
|
||||||
|
ORDER BY created_at DESC;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:16-alpine
|
image: postgres:16-alpine
|
||||||
ports:
|
ports:
|
||||||
- 5422:5432
|
- "5422:5432"
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_PASSWORD=secret
|
- POSTGRES_PASSWORD=secret
|
||||||
- POSTGRES_USER=root
|
- POSTGRES_USER=root
|
||||||
|
|
@ -19,6 +19,7 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- postgres_data:/var/lib/postgresql/data
|
- postgres_data:/var/lib/postgresql/data
|
||||||
- ./exports:/exports
|
- ./exports:/exports
|
||||||
|
|
||||||
mongo:
|
mongo:
|
||||||
container_name: fortunebet-mongo
|
container_name: fortunebet-mongo
|
||||||
image: mongo:7.0.11
|
image: mongo:7.0.11
|
||||||
|
|
@ -37,6 +38,7 @@ services:
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
|
|
||||||
migrate:
|
migrate:
|
||||||
image: migrate/migrate
|
image: migrate/migrate
|
||||||
volumes:
|
volumes:
|
||||||
|
|
@ -54,6 +56,7 @@ services:
|
||||||
]
|
]
|
||||||
networks:
|
networks:
|
||||||
- app
|
- app
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:7-alpine
|
image: redis:7-alpine
|
||||||
ports:
|
ports:
|
||||||
|
|
@ -66,17 +69,17 @@ services:
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
|
|
||||||
|
|
||||||
zookeeper:
|
zookeeper:
|
||||||
image: confluentinc/cp-zookeeper:7.5.0
|
image: confluentinc/cp-zookeeper:7.5.0
|
||||||
container_name: zookeeper
|
container_name: zookeeper
|
||||||
ports:
|
ports:
|
||||||
- "2181:2181"
|
- "22181:2181" # remapped host port (Windows-safe)
|
||||||
environment:
|
environment:
|
||||||
ZOOKEEPER_CLIENT_PORT: 2181
|
ZOOKEEPER_CLIENT_PORT: 2181
|
||||||
ZOOKEEPER_TICK_TIME: 2000
|
ZOOKEEPER_TICK_TIME: 2000
|
||||||
networks:
|
networks:
|
||||||
- app
|
- app
|
||||||
|
|
||||||
kafka:
|
kafka:
|
||||||
image: confluentinc/cp-kafka:7.5.0
|
image: confluentinc/cp-kafka:7.5.0
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|
@ -88,19 +91,19 @@ services:
|
||||||
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
|
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
|
||||||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
|
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
|
||||||
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
||||||
|
|
||||||
ports:
|
ports:
|
||||||
- "9092:9092"
|
- "9092:9092"
|
||||||
- "29092:29092"
|
- "29092:29092"
|
||||||
networks:
|
networks:
|
||||||
- app
|
- app
|
||||||
|
|
||||||
app:
|
app:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
target: runner
|
target: runner
|
||||||
ports:
|
ports:
|
||||||
- ${PORT}:8080
|
- "${PORT}:8080"
|
||||||
environment:
|
environment:
|
||||||
- DB_URL=postgresql://root:secret@postgres:5432/gh?sslmode=disable
|
- DB_URL=postgresql://root:secret@postgres:5432/gh?sslmode=disable
|
||||||
- MONGO_URI=mongodb://root:secret@mongo:27017
|
- MONGO_URI=mongodb://root:secret@mongo:27017
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,519 @@ import (
|
||||||
"github.com/jackc/pgx/v5/pgtype"
|
"github.com/jackc/pgx/v5/pgtype"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const CreateEnetpulseFixture = `-- name: CreateEnetpulseFixture :one
|
||||||
|
INSERT INTO enetpulse_fixtures (
|
||||||
|
fixture_id,
|
||||||
|
name,
|
||||||
|
sport_fk,
|
||||||
|
tournament_fk,
|
||||||
|
tournament_template_fk,
|
||||||
|
tournament_stage_fk,
|
||||||
|
tournament_stage_name,
|
||||||
|
tournament_name,
|
||||||
|
tournament_template_name,
|
||||||
|
sport_name,
|
||||||
|
gender,
|
||||||
|
start_date,
|
||||||
|
status_type,
|
||||||
|
status_desc_fk,
|
||||||
|
round_type_fk,
|
||||||
|
updates_count,
|
||||||
|
last_updated_at,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
) VALUES (
|
||||||
|
$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP
|
||||||
|
)
|
||||||
|
ON CONFLICT (fixture_id) DO UPDATE
|
||||||
|
SET
|
||||||
|
name = EXCLUDED.name,
|
||||||
|
sport_fk = EXCLUDED.sport_fk,
|
||||||
|
tournament_fk = EXCLUDED.tournament_fk,
|
||||||
|
tournament_template_fk = EXCLUDED.tournament_template_fk,
|
||||||
|
tournament_stage_fk = EXCLUDED.tournament_stage_fk,
|
||||||
|
tournament_stage_name = EXCLUDED.tournament_stage_name,
|
||||||
|
tournament_name = EXCLUDED.tournament_name,
|
||||||
|
tournament_template_name = EXCLUDED.tournament_template_name,
|
||||||
|
sport_name = EXCLUDED.sport_name,
|
||||||
|
gender = EXCLUDED.gender,
|
||||||
|
start_date = EXCLUDED.start_date,
|
||||||
|
status_type = EXCLUDED.status_type,
|
||||||
|
status_desc_fk = EXCLUDED.status_desc_fk,
|
||||||
|
round_type_fk = EXCLUDED.round_type_fk,
|
||||||
|
updates_count = EXCLUDED.updates_count,
|
||||||
|
last_updated_at = EXCLUDED.last_updated_at,
|
||||||
|
updated_at = CURRENT_TIMESTAMP
|
||||||
|
RETURNING id, fixture_id, name, sport_fk, tournament_fk, tournament_template_fk, tournament_stage_fk, tournament_stage_name, tournament_name, tournament_template_name, sport_name, gender, start_date, status_type, status_desc_fk, round_type_fk, updates_count, last_updated_at, created_at, updated_at
|
||||||
|
`
|
||||||
|
|
||||||
|
type CreateEnetpulseFixtureParams struct {
|
||||||
|
FixtureID string `json:"fixture_id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
SportFk string `json:"sport_fk"`
|
||||||
|
TournamentFk pgtype.Text `json:"tournament_fk"`
|
||||||
|
TournamentTemplateFk pgtype.Text `json:"tournament_template_fk"`
|
||||||
|
TournamentStageFk pgtype.Text `json:"tournament_stage_fk"`
|
||||||
|
TournamentStageName pgtype.Text `json:"tournament_stage_name"`
|
||||||
|
TournamentName pgtype.Text `json:"tournament_name"`
|
||||||
|
TournamentTemplateName pgtype.Text `json:"tournament_template_name"`
|
||||||
|
SportName pgtype.Text `json:"sport_name"`
|
||||||
|
Gender pgtype.Text `json:"gender"`
|
||||||
|
StartDate pgtype.Timestamptz `json:"start_date"`
|
||||||
|
StatusType pgtype.Text `json:"status_type"`
|
||||||
|
StatusDescFk pgtype.Text `json:"status_desc_fk"`
|
||||||
|
RoundTypeFk pgtype.Text `json:"round_type_fk"`
|
||||||
|
UpdatesCount pgtype.Int4 `json:"updates_count"`
|
||||||
|
LastUpdatedAt pgtype.Timestamptz `json:"last_updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) CreateEnetpulseFixture(ctx context.Context, arg CreateEnetpulseFixtureParams) (EnetpulseFixture, error) {
|
||||||
|
row := q.db.QueryRow(ctx, CreateEnetpulseFixture,
|
||||||
|
arg.FixtureID,
|
||||||
|
arg.Name,
|
||||||
|
arg.SportFk,
|
||||||
|
arg.TournamentFk,
|
||||||
|
arg.TournamentTemplateFk,
|
||||||
|
arg.TournamentStageFk,
|
||||||
|
arg.TournamentStageName,
|
||||||
|
arg.TournamentName,
|
||||||
|
arg.TournamentTemplateName,
|
||||||
|
arg.SportName,
|
||||||
|
arg.Gender,
|
||||||
|
arg.StartDate,
|
||||||
|
arg.StatusType,
|
||||||
|
arg.StatusDescFk,
|
||||||
|
arg.RoundTypeFk,
|
||||||
|
arg.UpdatesCount,
|
||||||
|
arg.LastUpdatedAt,
|
||||||
|
)
|
||||||
|
var i EnetpulseFixture
|
||||||
|
err := row.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.FixtureID,
|
||||||
|
&i.Name,
|
||||||
|
&i.SportFk,
|
||||||
|
&i.TournamentFk,
|
||||||
|
&i.TournamentTemplateFk,
|
||||||
|
&i.TournamentStageFk,
|
||||||
|
&i.TournamentStageName,
|
||||||
|
&i.TournamentName,
|
||||||
|
&i.TournamentTemplateName,
|
||||||
|
&i.SportName,
|
||||||
|
&i.Gender,
|
||||||
|
&i.StartDate,
|
||||||
|
&i.StatusType,
|
||||||
|
&i.StatusDescFk,
|
||||||
|
&i.RoundTypeFk,
|
||||||
|
&i.UpdatesCount,
|
||||||
|
&i.LastUpdatedAt,
|
||||||
|
&i.CreatedAt,
|
||||||
|
&i.UpdatedAt,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const CreateEnetpulseOutcomeType = `-- name: CreateEnetpulseOutcomeType :one
|
||||||
|
INSERT INTO enetpulse_outcome_types (
|
||||||
|
outcome_type_id,
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
updates_count,
|
||||||
|
last_updated_at,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
) VALUES (
|
||||||
|
$1, $2, $3, $4, $5, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
|
||||||
|
)
|
||||||
|
ON CONFLICT (outcome_type_id) DO UPDATE
|
||||||
|
SET
|
||||||
|
name = EXCLUDED.name,
|
||||||
|
description = EXCLUDED.description,
|
||||||
|
updates_count = EXCLUDED.updates_count,
|
||||||
|
last_updated_at = EXCLUDED.last_updated_at,
|
||||||
|
updated_at = CURRENT_TIMESTAMP
|
||||||
|
RETURNING id, outcome_type_id, name, description, updates_count, last_updated_at, created_at, updated_at
|
||||||
|
`
|
||||||
|
|
||||||
|
type CreateEnetpulseOutcomeTypeParams struct {
|
||||||
|
OutcomeTypeID string `json:"outcome_type_id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Description pgtype.Text `json:"description"`
|
||||||
|
UpdatesCount pgtype.Int4 `json:"updates_count"`
|
||||||
|
LastUpdatedAt pgtype.Timestamptz `json:"last_updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) CreateEnetpulseOutcomeType(ctx context.Context, arg CreateEnetpulseOutcomeTypeParams) (EnetpulseOutcomeType, error) {
|
||||||
|
row := q.db.QueryRow(ctx, CreateEnetpulseOutcomeType,
|
||||||
|
arg.OutcomeTypeID,
|
||||||
|
arg.Name,
|
||||||
|
arg.Description,
|
||||||
|
arg.UpdatesCount,
|
||||||
|
arg.LastUpdatedAt,
|
||||||
|
)
|
||||||
|
var i EnetpulseOutcomeType
|
||||||
|
err := row.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.OutcomeTypeID,
|
||||||
|
&i.Name,
|
||||||
|
&i.Description,
|
||||||
|
&i.UpdatesCount,
|
||||||
|
&i.LastUpdatedAt,
|
||||||
|
&i.CreatedAt,
|
||||||
|
&i.UpdatedAt,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const CreateEnetpulsePreodds = `-- name: CreateEnetpulsePreodds :one
|
||||||
|
INSERT INTO enetpulse_preodds (
|
||||||
|
preodds_id,
|
||||||
|
event_fk,
|
||||||
|
outcome_type_fk,
|
||||||
|
outcome_scope_fk,
|
||||||
|
outcome_subtype_fk,
|
||||||
|
event_participant_number,
|
||||||
|
iparam,
|
||||||
|
iparam2,
|
||||||
|
dparam,
|
||||||
|
dparam2,
|
||||||
|
sparam,
|
||||||
|
updates_count,
|
||||||
|
last_updated_at,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
) VALUES (
|
||||||
|
$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP
|
||||||
|
)
|
||||||
|
ON CONFLICT (preodds_id) DO UPDATE
|
||||||
|
SET
|
||||||
|
event_fk = EXCLUDED.event_fk,
|
||||||
|
outcome_type_fk = EXCLUDED.outcome_type_fk,
|
||||||
|
outcome_scope_fk = EXCLUDED.outcome_scope_fk,
|
||||||
|
outcome_subtype_fk = EXCLUDED.outcome_subtype_fk,
|
||||||
|
event_participant_number = EXCLUDED.event_participant_number,
|
||||||
|
iparam = EXCLUDED.iparam,
|
||||||
|
iparam2 = EXCLUDED.iparam2,
|
||||||
|
dparam = EXCLUDED.dparam,
|
||||||
|
dparam2 = EXCLUDED.dparam2,
|
||||||
|
sparam = EXCLUDED.sparam,
|
||||||
|
updates_count = EXCLUDED.updates_count,
|
||||||
|
last_updated_at = EXCLUDED.last_updated_at,
|
||||||
|
updated_at = CURRENT_TIMESTAMP
|
||||||
|
RETURNING id, preodds_id, event_fk, outcome_type_fk, outcome_scope_fk, outcome_subtype_fk, event_participant_number, iparam, iparam2, dparam, dparam2, sparam, updates_count, last_updated_at, created_at, updated_at
|
||||||
|
`
|
||||||
|
|
||||||
|
type CreateEnetpulsePreoddsParams struct {
|
||||||
|
PreoddsID string `json:"preodds_id"`
|
||||||
|
EventFk int64 `json:"event_fk"`
|
||||||
|
OutcomeTypeFk pgtype.Int4 `json:"outcome_type_fk"`
|
||||||
|
OutcomeScopeFk pgtype.Int4 `json:"outcome_scope_fk"`
|
||||||
|
OutcomeSubtypeFk pgtype.Int4 `json:"outcome_subtype_fk"`
|
||||||
|
EventParticipantNumber pgtype.Int4 `json:"event_participant_number"`
|
||||||
|
Iparam pgtype.Text `json:"iparam"`
|
||||||
|
Iparam2 pgtype.Text `json:"iparam2"`
|
||||||
|
Dparam pgtype.Text `json:"dparam"`
|
||||||
|
Dparam2 pgtype.Text `json:"dparam2"`
|
||||||
|
Sparam pgtype.Text `json:"sparam"`
|
||||||
|
UpdatesCount pgtype.Int4 `json:"updates_count"`
|
||||||
|
LastUpdatedAt pgtype.Timestamptz `json:"last_updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) CreateEnetpulsePreodds(ctx context.Context, arg CreateEnetpulsePreoddsParams) (EnetpulsePreodd, error) {
|
||||||
|
row := q.db.QueryRow(ctx, CreateEnetpulsePreodds,
|
||||||
|
arg.PreoddsID,
|
||||||
|
arg.EventFk,
|
||||||
|
arg.OutcomeTypeFk,
|
||||||
|
arg.OutcomeScopeFk,
|
||||||
|
arg.OutcomeSubtypeFk,
|
||||||
|
arg.EventParticipantNumber,
|
||||||
|
arg.Iparam,
|
||||||
|
arg.Iparam2,
|
||||||
|
arg.Dparam,
|
||||||
|
arg.Dparam2,
|
||||||
|
arg.Sparam,
|
||||||
|
arg.UpdatesCount,
|
||||||
|
arg.LastUpdatedAt,
|
||||||
|
)
|
||||||
|
var i EnetpulsePreodd
|
||||||
|
err := row.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.PreoddsID,
|
||||||
|
&i.EventFk,
|
||||||
|
&i.OutcomeTypeFk,
|
||||||
|
&i.OutcomeScopeFk,
|
||||||
|
&i.OutcomeSubtypeFk,
|
||||||
|
&i.EventParticipantNumber,
|
||||||
|
&i.Iparam,
|
||||||
|
&i.Iparam2,
|
||||||
|
&i.Dparam,
|
||||||
|
&i.Dparam2,
|
||||||
|
&i.Sparam,
|
||||||
|
&i.UpdatesCount,
|
||||||
|
&i.LastUpdatedAt,
|
||||||
|
&i.CreatedAt,
|
||||||
|
&i.UpdatedAt,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const CreateEnetpulsePreoddsBettingOffer = `-- name: CreateEnetpulsePreoddsBettingOffer :one
|
||||||
|
INSERT INTO enetpulse_preodds_bettingoffers (
|
||||||
|
bettingoffer_id,
|
||||||
|
preodds_fk,
|
||||||
|
bettingoffer_status_fk,
|
||||||
|
odds_provider_fk,
|
||||||
|
odds,
|
||||||
|
odds_old,
|
||||||
|
active,
|
||||||
|
coupon_key,
|
||||||
|
updates_count,
|
||||||
|
last_updated_at,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
) VALUES (
|
||||||
|
$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP
|
||||||
|
)
|
||||||
|
ON CONFLICT (bettingoffer_id) DO UPDATE
|
||||||
|
SET
|
||||||
|
preodds_fk = EXCLUDED.preodds_fk,
|
||||||
|
bettingoffer_status_fk = EXCLUDED.bettingoffer_status_fk,
|
||||||
|
odds_provider_fk = EXCLUDED.odds_provider_fk,
|
||||||
|
odds = EXCLUDED.odds,
|
||||||
|
odds_old = EXCLUDED.odds_old,
|
||||||
|
active = EXCLUDED.active,
|
||||||
|
coupon_key = EXCLUDED.coupon_key,
|
||||||
|
updates_count = EXCLUDED.updates_count,
|
||||||
|
last_updated_at = EXCLUDED.last_updated_at,
|
||||||
|
updated_at = CURRENT_TIMESTAMP
|
||||||
|
RETURNING id, bettingoffer_id, preodds_fk, bettingoffer_status_fk, odds_provider_fk, odds, odds_old, active, coupon_key, updates_count, last_updated_at, created_at, updated_at
|
||||||
|
`
|
||||||
|
|
||||||
|
type CreateEnetpulsePreoddsBettingOfferParams struct {
|
||||||
|
BettingofferID string `json:"bettingoffer_id"`
|
||||||
|
PreoddsFk string `json:"preodds_fk"`
|
||||||
|
BettingofferStatusFk pgtype.Int4 `json:"bettingoffer_status_fk"`
|
||||||
|
OddsProviderFk pgtype.Int4 `json:"odds_provider_fk"`
|
||||||
|
Odds pgtype.Numeric `json:"odds"`
|
||||||
|
OddsOld pgtype.Numeric `json:"odds_old"`
|
||||||
|
Active pgtype.Bool `json:"active"`
|
||||||
|
CouponKey pgtype.Text `json:"coupon_key"`
|
||||||
|
UpdatesCount pgtype.Int4 `json:"updates_count"`
|
||||||
|
LastUpdatedAt pgtype.Timestamptz `json:"last_updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) CreateEnetpulsePreoddsBettingOffer(ctx context.Context, arg CreateEnetpulsePreoddsBettingOfferParams) (EnetpulsePreoddsBettingoffer, error) {
|
||||||
|
row := q.db.QueryRow(ctx, CreateEnetpulsePreoddsBettingOffer,
|
||||||
|
arg.BettingofferID,
|
||||||
|
arg.PreoddsFk,
|
||||||
|
arg.BettingofferStatusFk,
|
||||||
|
arg.OddsProviderFk,
|
||||||
|
arg.Odds,
|
||||||
|
arg.OddsOld,
|
||||||
|
arg.Active,
|
||||||
|
arg.CouponKey,
|
||||||
|
arg.UpdatesCount,
|
||||||
|
arg.LastUpdatedAt,
|
||||||
|
)
|
||||||
|
var i EnetpulsePreoddsBettingoffer
|
||||||
|
err := row.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.BettingofferID,
|
||||||
|
&i.PreoddsFk,
|
||||||
|
&i.BettingofferStatusFk,
|
||||||
|
&i.OddsProviderFk,
|
||||||
|
&i.Odds,
|
||||||
|
&i.OddsOld,
|
||||||
|
&i.Active,
|
||||||
|
&i.CouponKey,
|
||||||
|
&i.UpdatesCount,
|
||||||
|
&i.LastUpdatedAt,
|
||||||
|
&i.CreatedAt,
|
||||||
|
&i.UpdatedAt,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const CreateEnetpulseResult = `-- name: CreateEnetpulseResult :one
|
||||||
|
INSERT INTO enetpulse_results (
|
||||||
|
result_id,
|
||||||
|
name,
|
||||||
|
sport_fk,
|
||||||
|
tournament_fk,
|
||||||
|
tournament_template_fk,
|
||||||
|
tournament_stage_fk,
|
||||||
|
tournament_stage_name,
|
||||||
|
tournament_name,
|
||||||
|
tournament_template_name,
|
||||||
|
sport_name,
|
||||||
|
start_date,
|
||||||
|
status_type,
|
||||||
|
status_desc_fk,
|
||||||
|
round_type_fk,
|
||||||
|
updates_count,
|
||||||
|
last_updated_at,
|
||||||
|
round,
|
||||||
|
live,
|
||||||
|
venue_name,
|
||||||
|
livestats_plus,
|
||||||
|
livestats_type,
|
||||||
|
commentary,
|
||||||
|
lineup_confirmed,
|
||||||
|
verified,
|
||||||
|
spectators,
|
||||||
|
game_started,
|
||||||
|
first_half_ended,
|
||||||
|
second_half_started,
|
||||||
|
second_half_ended,
|
||||||
|
game_ended
|
||||||
|
) VALUES (
|
||||||
|
$1, $2, $3, $4, $5, $6,
|
||||||
|
$7, $8, $9, $10, $11,
|
||||||
|
$12, $13, $14, $15, $16,
|
||||||
|
$17, $18, $19, $20, $21,
|
||||||
|
$22, $23, $24, $25, $26,
|
||||||
|
$27, $28, $29, $30
|
||||||
|
)
|
||||||
|
ON CONFLICT (result_id) DO UPDATE
|
||||||
|
SET
|
||||||
|
name = EXCLUDED.name,
|
||||||
|
sport_fk = EXCLUDED.sport_fk,
|
||||||
|
tournament_fk = EXCLUDED.tournament_fk,
|
||||||
|
tournament_template_fk = EXCLUDED.tournament_template_fk,
|
||||||
|
tournament_stage_fk = EXCLUDED.tournament_stage_fk,
|
||||||
|
tournament_stage_name = EXCLUDED.tournament_stage_name,
|
||||||
|
tournament_name = EXCLUDED.tournament_name,
|
||||||
|
tournament_template_name = EXCLUDED.tournament_template_name,
|
||||||
|
sport_name = EXCLUDED.sport_name,
|
||||||
|
start_date = EXCLUDED.start_date,
|
||||||
|
status_type = EXCLUDED.status_type,
|
||||||
|
status_desc_fk = EXCLUDED.status_desc_fk,
|
||||||
|
round_type_fk = EXCLUDED.round_type_fk,
|
||||||
|
updates_count = EXCLUDED.updates_count,
|
||||||
|
last_updated_at = EXCLUDED.last_updated_at,
|
||||||
|
round = EXCLUDED.round,
|
||||||
|
live = EXCLUDED.live,
|
||||||
|
venue_name = EXCLUDED.venue_name,
|
||||||
|
livestats_plus = EXCLUDED.livestats_plus,
|
||||||
|
livestats_type = EXCLUDED.livestats_type,
|
||||||
|
commentary = EXCLUDED.commentary,
|
||||||
|
lineup_confirmed = EXCLUDED.lineup_confirmed,
|
||||||
|
verified = EXCLUDED.verified,
|
||||||
|
spectators = EXCLUDED.spectators,
|
||||||
|
game_started = EXCLUDED.game_started,
|
||||||
|
first_half_ended = EXCLUDED.first_half_ended,
|
||||||
|
second_half_started = EXCLUDED.second_half_started,
|
||||||
|
second_half_ended = EXCLUDED.second_half_ended,
|
||||||
|
game_ended = EXCLUDED.game_ended,
|
||||||
|
updated_at = CURRENT_TIMESTAMP
|
||||||
|
RETURNING id, result_id, name, sport_fk, tournament_fk, tournament_template_fk, tournament_stage_fk, tournament_stage_name, tournament_name, tournament_template_name, sport_name, start_date, status_type, status_desc_fk, round_type_fk, updates_count, last_updated_at, round, live, venue_name, livestats_plus, livestats_type, commentary, lineup_confirmed, verified, spectators, game_started, first_half_ended, second_half_started, second_half_ended, game_ended, created_at, updated_at
|
||||||
|
`
|
||||||
|
|
||||||
|
type CreateEnetpulseResultParams struct {
|
||||||
|
ResultID string `json:"result_id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
SportFk string `json:"sport_fk"`
|
||||||
|
TournamentFk pgtype.Text `json:"tournament_fk"`
|
||||||
|
TournamentTemplateFk pgtype.Text `json:"tournament_template_fk"`
|
||||||
|
TournamentStageFk pgtype.Text `json:"tournament_stage_fk"`
|
||||||
|
TournamentStageName pgtype.Text `json:"tournament_stage_name"`
|
||||||
|
TournamentName pgtype.Text `json:"tournament_name"`
|
||||||
|
TournamentTemplateName pgtype.Text `json:"tournament_template_name"`
|
||||||
|
SportName pgtype.Text `json:"sport_name"`
|
||||||
|
StartDate pgtype.Timestamptz `json:"start_date"`
|
||||||
|
StatusType pgtype.Text `json:"status_type"`
|
||||||
|
StatusDescFk pgtype.Text `json:"status_desc_fk"`
|
||||||
|
RoundTypeFk pgtype.Text `json:"round_type_fk"`
|
||||||
|
UpdatesCount pgtype.Int4 `json:"updates_count"`
|
||||||
|
LastUpdatedAt pgtype.Timestamptz `json:"last_updated_at"`
|
||||||
|
Round pgtype.Text `json:"round"`
|
||||||
|
Live pgtype.Text `json:"live"`
|
||||||
|
VenueName pgtype.Text `json:"venue_name"`
|
||||||
|
LivestatsPlus pgtype.Text `json:"livestats_plus"`
|
||||||
|
LivestatsType pgtype.Text `json:"livestats_type"`
|
||||||
|
Commentary pgtype.Text `json:"commentary"`
|
||||||
|
LineupConfirmed pgtype.Bool `json:"lineup_confirmed"`
|
||||||
|
Verified pgtype.Bool `json:"verified"`
|
||||||
|
Spectators pgtype.Int4 `json:"spectators"`
|
||||||
|
GameStarted pgtype.Timestamptz `json:"game_started"`
|
||||||
|
FirstHalfEnded pgtype.Timestamptz `json:"first_half_ended"`
|
||||||
|
SecondHalfStarted pgtype.Timestamptz `json:"second_half_started"`
|
||||||
|
SecondHalfEnded pgtype.Timestamptz `json:"second_half_ended"`
|
||||||
|
GameEnded pgtype.Timestamptz `json:"game_ended"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) CreateEnetpulseResult(ctx context.Context, arg CreateEnetpulseResultParams) (EnetpulseResult, error) {
|
||||||
|
row := q.db.QueryRow(ctx, CreateEnetpulseResult,
|
||||||
|
arg.ResultID,
|
||||||
|
arg.Name,
|
||||||
|
arg.SportFk,
|
||||||
|
arg.TournamentFk,
|
||||||
|
arg.TournamentTemplateFk,
|
||||||
|
arg.TournamentStageFk,
|
||||||
|
arg.TournamentStageName,
|
||||||
|
arg.TournamentName,
|
||||||
|
arg.TournamentTemplateName,
|
||||||
|
arg.SportName,
|
||||||
|
arg.StartDate,
|
||||||
|
arg.StatusType,
|
||||||
|
arg.StatusDescFk,
|
||||||
|
arg.RoundTypeFk,
|
||||||
|
arg.UpdatesCount,
|
||||||
|
arg.LastUpdatedAt,
|
||||||
|
arg.Round,
|
||||||
|
arg.Live,
|
||||||
|
arg.VenueName,
|
||||||
|
arg.LivestatsPlus,
|
||||||
|
arg.LivestatsType,
|
||||||
|
arg.Commentary,
|
||||||
|
arg.LineupConfirmed,
|
||||||
|
arg.Verified,
|
||||||
|
arg.Spectators,
|
||||||
|
arg.GameStarted,
|
||||||
|
arg.FirstHalfEnded,
|
||||||
|
arg.SecondHalfStarted,
|
||||||
|
arg.SecondHalfEnded,
|
||||||
|
arg.GameEnded,
|
||||||
|
)
|
||||||
|
var i EnetpulseResult
|
||||||
|
err := row.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.ResultID,
|
||||||
|
&i.Name,
|
||||||
|
&i.SportFk,
|
||||||
|
&i.TournamentFk,
|
||||||
|
&i.TournamentTemplateFk,
|
||||||
|
&i.TournamentStageFk,
|
||||||
|
&i.TournamentStageName,
|
||||||
|
&i.TournamentName,
|
||||||
|
&i.TournamentTemplateName,
|
||||||
|
&i.SportName,
|
||||||
|
&i.StartDate,
|
||||||
|
&i.StatusType,
|
||||||
|
&i.StatusDescFk,
|
||||||
|
&i.RoundTypeFk,
|
||||||
|
&i.UpdatesCount,
|
||||||
|
&i.LastUpdatedAt,
|
||||||
|
&i.Round,
|
||||||
|
&i.Live,
|
||||||
|
&i.VenueName,
|
||||||
|
&i.LivestatsPlus,
|
||||||
|
&i.LivestatsType,
|
||||||
|
&i.Commentary,
|
||||||
|
&i.LineupConfirmed,
|
||||||
|
&i.Verified,
|
||||||
|
&i.Spectators,
|
||||||
|
&i.GameStarted,
|
||||||
|
&i.FirstHalfEnded,
|
||||||
|
&i.SecondHalfStarted,
|
||||||
|
&i.SecondHalfEnded,
|
||||||
|
&i.GameEnded,
|
||||||
|
&i.CreatedAt,
|
||||||
|
&i.UpdatedAt,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
const CreateEnetpulseSport = `-- name: CreateEnetpulseSport :one
|
const CreateEnetpulseSport = `-- name: CreateEnetpulseSport :one
|
||||||
INSERT INTO enetpulse_sports (
|
INSERT INTO enetpulse_sports (
|
||||||
sport_id,
|
sport_id,
|
||||||
|
|
@ -63,6 +576,7 @@ func (q *Queries) CreateEnetpulseSport(ctx context.Context, arg CreateEnetpulseS
|
||||||
}
|
}
|
||||||
|
|
||||||
const CreateEnetpulseTournament = `-- name: CreateEnetpulseTournament :one
|
const CreateEnetpulseTournament = `-- name: CreateEnetpulseTournament :one
|
||||||
|
|
||||||
INSERT INTO enetpulse_tournaments (
|
INSERT INTO enetpulse_tournaments (
|
||||||
tournament_id,
|
tournament_id,
|
||||||
name,
|
name,
|
||||||
|
|
@ -90,6 +604,8 @@ type CreateEnetpulseTournamentParams struct {
|
||||||
Status pgtype.Int4 `json:"status"`
|
Status pgtype.Int4 `json:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -- name: DeleteEnetpulseTournamentTemplateByID :exec
|
||||||
|
// DELETE FROM enetpulse_tournament_templates WHERE template_id = $1;
|
||||||
func (q *Queries) CreateEnetpulseTournament(ctx context.Context, arg CreateEnetpulseTournamentParams) (EnetpulseTournament, error) {
|
func (q *Queries) CreateEnetpulseTournament(ctx context.Context, arg CreateEnetpulseTournamentParams) (EnetpulseTournament, error) {
|
||||||
row := q.db.QueryRow(ctx, CreateEnetpulseTournament,
|
row := q.db.QueryRow(ctx, CreateEnetpulseTournament,
|
||||||
arg.TournamentID,
|
arg.TournamentID,
|
||||||
|
|
@ -250,6 +766,231 @@ func (q *Queries) CreateEnetpulseTournamentTemplate(ctx context.Context, arg Cre
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const GetAllEnetpulseFixtures = `-- name: GetAllEnetpulseFixtures :many
|
||||||
|
SELECT id, fixture_id, name, sport_fk, tournament_fk, tournament_template_fk, tournament_stage_fk, tournament_stage_name, tournament_name, tournament_template_name, sport_name, gender, start_date, status_type, status_desc_fk, round_type_fk, updates_count, last_updated_at, created_at, updated_at
|
||||||
|
FROM enetpulse_fixtures
|
||||||
|
ORDER BY created_at DESC
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetAllEnetpulseFixtures(ctx context.Context) ([]EnetpulseFixture, error) {
|
||||||
|
rows, err := q.db.Query(ctx, GetAllEnetpulseFixtures)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
var items []EnetpulseFixture
|
||||||
|
for rows.Next() {
|
||||||
|
var i EnetpulseFixture
|
||||||
|
if err := rows.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.FixtureID,
|
||||||
|
&i.Name,
|
||||||
|
&i.SportFk,
|
||||||
|
&i.TournamentFk,
|
||||||
|
&i.TournamentTemplateFk,
|
||||||
|
&i.TournamentStageFk,
|
||||||
|
&i.TournamentStageName,
|
||||||
|
&i.TournamentName,
|
||||||
|
&i.TournamentTemplateName,
|
||||||
|
&i.SportName,
|
||||||
|
&i.Gender,
|
||||||
|
&i.StartDate,
|
||||||
|
&i.StatusType,
|
||||||
|
&i.StatusDescFk,
|
||||||
|
&i.RoundTypeFk,
|
||||||
|
&i.UpdatesCount,
|
||||||
|
&i.LastUpdatedAt,
|
||||||
|
&i.CreatedAt,
|
||||||
|
&i.UpdatedAt,
|
||||||
|
); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
items = append(items, i)
|
||||||
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return items, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
const GetAllEnetpulseOutcomeTypes = `-- name: GetAllEnetpulseOutcomeTypes :many
|
||||||
|
SELECT id, outcome_type_id, name, description, updates_count, last_updated_at, created_at, updated_at
|
||||||
|
FROM enetpulse_outcome_types
|
||||||
|
ORDER BY created_at DESC
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetAllEnetpulseOutcomeTypes(ctx context.Context) ([]EnetpulseOutcomeType, error) {
|
||||||
|
rows, err := q.db.Query(ctx, GetAllEnetpulseOutcomeTypes)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
var items []EnetpulseOutcomeType
|
||||||
|
for rows.Next() {
|
||||||
|
var i EnetpulseOutcomeType
|
||||||
|
if err := rows.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.OutcomeTypeID,
|
||||||
|
&i.Name,
|
||||||
|
&i.Description,
|
||||||
|
&i.UpdatesCount,
|
||||||
|
&i.LastUpdatedAt,
|
||||||
|
&i.CreatedAt,
|
||||||
|
&i.UpdatedAt,
|
||||||
|
); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
items = append(items, i)
|
||||||
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return items, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
const GetAllEnetpulsePreodds = `-- name: GetAllEnetpulsePreodds :many
|
||||||
|
SELECT id, preodds_id, event_fk, outcome_type_fk, outcome_scope_fk, outcome_subtype_fk, event_participant_number, iparam, iparam2, dparam, dparam2, sparam, updates_count, last_updated_at, created_at, updated_at
|
||||||
|
FROM enetpulse_preodds
|
||||||
|
ORDER BY created_at DESC
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetAllEnetpulsePreodds(ctx context.Context) ([]EnetpulsePreodd, error) {
|
||||||
|
rows, err := q.db.Query(ctx, GetAllEnetpulsePreodds)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
var items []EnetpulsePreodd
|
||||||
|
for rows.Next() {
|
||||||
|
var i EnetpulsePreodd
|
||||||
|
if err := rows.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.PreoddsID,
|
||||||
|
&i.EventFk,
|
||||||
|
&i.OutcomeTypeFk,
|
||||||
|
&i.OutcomeScopeFk,
|
||||||
|
&i.OutcomeSubtypeFk,
|
||||||
|
&i.EventParticipantNumber,
|
||||||
|
&i.Iparam,
|
||||||
|
&i.Iparam2,
|
||||||
|
&i.Dparam,
|
||||||
|
&i.Dparam2,
|
||||||
|
&i.Sparam,
|
||||||
|
&i.UpdatesCount,
|
||||||
|
&i.LastUpdatedAt,
|
||||||
|
&i.CreatedAt,
|
||||||
|
&i.UpdatedAt,
|
||||||
|
); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
items = append(items, i)
|
||||||
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return items, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
const GetAllEnetpulsePreoddsBettingOffers = `-- name: GetAllEnetpulsePreoddsBettingOffers :many
|
||||||
|
SELECT id, bettingoffer_id, preodds_fk, bettingoffer_status_fk, odds_provider_fk, odds, odds_old, active, coupon_key, updates_count, last_updated_at, created_at, updated_at
|
||||||
|
FROM enetpulse_preodds_bettingoffers
|
||||||
|
ORDER BY created_at DESC
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetAllEnetpulsePreoddsBettingOffers(ctx context.Context) ([]EnetpulsePreoddsBettingoffer, error) {
|
||||||
|
rows, err := q.db.Query(ctx, GetAllEnetpulsePreoddsBettingOffers)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
var items []EnetpulsePreoddsBettingoffer
|
||||||
|
for rows.Next() {
|
||||||
|
var i EnetpulsePreoddsBettingoffer
|
||||||
|
if err := rows.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.BettingofferID,
|
||||||
|
&i.PreoddsFk,
|
||||||
|
&i.BettingofferStatusFk,
|
||||||
|
&i.OddsProviderFk,
|
||||||
|
&i.Odds,
|
||||||
|
&i.OddsOld,
|
||||||
|
&i.Active,
|
||||||
|
&i.CouponKey,
|
||||||
|
&i.UpdatesCount,
|
||||||
|
&i.LastUpdatedAt,
|
||||||
|
&i.CreatedAt,
|
||||||
|
&i.UpdatedAt,
|
||||||
|
); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
items = append(items, i)
|
||||||
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return items, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
const GetAllEnetpulseResults = `-- name: GetAllEnetpulseResults :many
|
||||||
|
SELECT id, result_id, name, sport_fk, tournament_fk, tournament_template_fk, tournament_stage_fk, tournament_stage_name, tournament_name, tournament_template_name, sport_name, start_date, status_type, status_desc_fk, round_type_fk, updates_count, last_updated_at, round, live, venue_name, livestats_plus, livestats_type, commentary, lineup_confirmed, verified, spectators, game_started, first_half_ended, second_half_started, second_half_ended, game_ended, created_at, updated_at
|
||||||
|
FROM enetpulse_results
|
||||||
|
ORDER BY created_at DESC
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetAllEnetpulseResults(ctx context.Context) ([]EnetpulseResult, error) {
|
||||||
|
rows, err := q.db.Query(ctx, GetAllEnetpulseResults)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
var items []EnetpulseResult
|
||||||
|
for rows.Next() {
|
||||||
|
var i EnetpulseResult
|
||||||
|
if err := rows.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.ResultID,
|
||||||
|
&i.Name,
|
||||||
|
&i.SportFk,
|
||||||
|
&i.TournamentFk,
|
||||||
|
&i.TournamentTemplateFk,
|
||||||
|
&i.TournamentStageFk,
|
||||||
|
&i.TournamentStageName,
|
||||||
|
&i.TournamentName,
|
||||||
|
&i.TournamentTemplateName,
|
||||||
|
&i.SportName,
|
||||||
|
&i.StartDate,
|
||||||
|
&i.StatusType,
|
||||||
|
&i.StatusDescFk,
|
||||||
|
&i.RoundTypeFk,
|
||||||
|
&i.UpdatesCount,
|
||||||
|
&i.LastUpdatedAt,
|
||||||
|
&i.Round,
|
||||||
|
&i.Live,
|
||||||
|
&i.VenueName,
|
||||||
|
&i.LivestatsPlus,
|
||||||
|
&i.LivestatsType,
|
||||||
|
&i.Commentary,
|
||||||
|
&i.LineupConfirmed,
|
||||||
|
&i.Verified,
|
||||||
|
&i.Spectators,
|
||||||
|
&i.GameStarted,
|
||||||
|
&i.FirstHalfEnded,
|
||||||
|
&i.SecondHalfStarted,
|
||||||
|
&i.SecondHalfEnded,
|
||||||
|
&i.GameEnded,
|
||||||
|
&i.CreatedAt,
|
||||||
|
&i.UpdatedAt,
|
||||||
|
); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
items = append(items, i)
|
||||||
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return items, nil
|
||||||
|
}
|
||||||
|
|
||||||
const GetAllEnetpulseSports = `-- name: GetAllEnetpulseSports :many
|
const GetAllEnetpulseSports = `-- name: GetAllEnetpulseSports :many
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
id,
|
||||||
|
|
|
||||||
137
gen/db/models.go
137
gen/db/models.go
|
|
@ -256,6 +256,143 @@ type DisabledOdd struct {
|
||||||
CreatedAt pgtype.Timestamp `json:"created_at"`
|
CreatedAt pgtype.Timestamp `json:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type EnetpulseFixture struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
FixtureID string `json:"fixture_id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
SportFk string `json:"sport_fk"`
|
||||||
|
TournamentFk pgtype.Text `json:"tournament_fk"`
|
||||||
|
TournamentTemplateFk pgtype.Text `json:"tournament_template_fk"`
|
||||||
|
TournamentStageFk pgtype.Text `json:"tournament_stage_fk"`
|
||||||
|
TournamentStageName pgtype.Text `json:"tournament_stage_name"`
|
||||||
|
TournamentName pgtype.Text `json:"tournament_name"`
|
||||||
|
TournamentTemplateName pgtype.Text `json:"tournament_template_name"`
|
||||||
|
SportName pgtype.Text `json:"sport_name"`
|
||||||
|
Gender pgtype.Text `json:"gender"`
|
||||||
|
StartDate pgtype.Timestamptz `json:"start_date"`
|
||||||
|
StatusType pgtype.Text `json:"status_type"`
|
||||||
|
StatusDescFk pgtype.Text `json:"status_desc_fk"`
|
||||||
|
RoundTypeFk pgtype.Text `json:"round_type_fk"`
|
||||||
|
UpdatesCount pgtype.Int4 `json:"updates_count"`
|
||||||
|
LastUpdatedAt pgtype.Timestamptz `json:"last_updated_at"`
|
||||||
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||||
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type EnetpulseOutcomeType struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
OutcomeTypeID string `json:"outcome_type_id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Description pgtype.Text `json:"description"`
|
||||||
|
UpdatesCount pgtype.Int4 `json:"updates_count"`
|
||||||
|
LastUpdatedAt pgtype.Timestamptz `json:"last_updated_at"`
|
||||||
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||||
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type EnetpulsePreodd struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
PreoddsID string `json:"preodds_id"`
|
||||||
|
EventFk int64 `json:"event_fk"`
|
||||||
|
OutcomeTypeFk pgtype.Int4 `json:"outcome_type_fk"`
|
||||||
|
OutcomeScopeFk pgtype.Int4 `json:"outcome_scope_fk"`
|
||||||
|
OutcomeSubtypeFk pgtype.Int4 `json:"outcome_subtype_fk"`
|
||||||
|
EventParticipantNumber pgtype.Int4 `json:"event_participant_number"`
|
||||||
|
Iparam pgtype.Text `json:"iparam"`
|
||||||
|
Iparam2 pgtype.Text `json:"iparam2"`
|
||||||
|
Dparam pgtype.Text `json:"dparam"`
|
||||||
|
Dparam2 pgtype.Text `json:"dparam2"`
|
||||||
|
Sparam pgtype.Text `json:"sparam"`
|
||||||
|
UpdatesCount pgtype.Int4 `json:"updates_count"`
|
||||||
|
LastUpdatedAt pgtype.Timestamptz `json:"last_updated_at"`
|
||||||
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||||
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type EnetpulsePreoddsBettingoffer struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
BettingofferID string `json:"bettingoffer_id"`
|
||||||
|
PreoddsFk string `json:"preodds_fk"`
|
||||||
|
BettingofferStatusFk pgtype.Int4 `json:"bettingoffer_status_fk"`
|
||||||
|
OddsProviderFk pgtype.Int4 `json:"odds_provider_fk"`
|
||||||
|
Odds pgtype.Numeric `json:"odds"`
|
||||||
|
OddsOld pgtype.Numeric `json:"odds_old"`
|
||||||
|
Active pgtype.Bool `json:"active"`
|
||||||
|
CouponKey pgtype.Text `json:"coupon_key"`
|
||||||
|
UpdatesCount pgtype.Int4 `json:"updates_count"`
|
||||||
|
LastUpdatedAt pgtype.Timestamptz `json:"last_updated_at"`
|
||||||
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||||
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type EnetpulseResult struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
ResultID string `json:"result_id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
SportFk string `json:"sport_fk"`
|
||||||
|
TournamentFk pgtype.Text `json:"tournament_fk"`
|
||||||
|
TournamentTemplateFk pgtype.Text `json:"tournament_template_fk"`
|
||||||
|
TournamentStageFk pgtype.Text `json:"tournament_stage_fk"`
|
||||||
|
TournamentStageName pgtype.Text `json:"tournament_stage_name"`
|
||||||
|
TournamentName pgtype.Text `json:"tournament_name"`
|
||||||
|
TournamentTemplateName pgtype.Text `json:"tournament_template_name"`
|
||||||
|
SportName pgtype.Text `json:"sport_name"`
|
||||||
|
StartDate pgtype.Timestamptz `json:"start_date"`
|
||||||
|
StatusType pgtype.Text `json:"status_type"`
|
||||||
|
StatusDescFk pgtype.Text `json:"status_desc_fk"`
|
||||||
|
RoundTypeFk pgtype.Text `json:"round_type_fk"`
|
||||||
|
UpdatesCount pgtype.Int4 `json:"updates_count"`
|
||||||
|
LastUpdatedAt pgtype.Timestamptz `json:"last_updated_at"`
|
||||||
|
Round pgtype.Text `json:"round"`
|
||||||
|
Live pgtype.Text `json:"live"`
|
||||||
|
VenueName pgtype.Text `json:"venue_name"`
|
||||||
|
LivestatsPlus pgtype.Text `json:"livestats_plus"`
|
||||||
|
LivestatsType pgtype.Text `json:"livestats_type"`
|
||||||
|
Commentary pgtype.Text `json:"commentary"`
|
||||||
|
LineupConfirmed pgtype.Bool `json:"lineup_confirmed"`
|
||||||
|
Verified pgtype.Bool `json:"verified"`
|
||||||
|
Spectators pgtype.Int4 `json:"spectators"`
|
||||||
|
GameStarted pgtype.Timestamptz `json:"game_started"`
|
||||||
|
FirstHalfEnded pgtype.Timestamptz `json:"first_half_ended"`
|
||||||
|
SecondHalfStarted pgtype.Timestamptz `json:"second_half_started"`
|
||||||
|
SecondHalfEnded pgtype.Timestamptz `json:"second_half_ended"`
|
||||||
|
GameEnded pgtype.Timestamptz `json:"game_ended"`
|
||||||
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||||
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type EnetpulseResultParticipant struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
ParticipantMapID string `json:"participant_map_id"`
|
||||||
|
ResultFk string `json:"result_fk"`
|
||||||
|
ParticipantFk string `json:"participant_fk"`
|
||||||
|
Number pgtype.Int4 `json:"number"`
|
||||||
|
Name pgtype.Text `json:"name"`
|
||||||
|
Gender pgtype.Text `json:"gender"`
|
||||||
|
Type pgtype.Text `json:"type"`
|
||||||
|
CountryFk pgtype.Text `json:"country_fk"`
|
||||||
|
CountryName pgtype.Text `json:"country_name"`
|
||||||
|
OrdinaryTime pgtype.Text `json:"ordinary_time"`
|
||||||
|
RunningScore pgtype.Text `json:"running_score"`
|
||||||
|
Halftime pgtype.Text `json:"halftime"`
|
||||||
|
FinalResult pgtype.Text `json:"final_result"`
|
||||||
|
LastUpdatedAt pgtype.Timestamptz `json:"last_updated_at"`
|
||||||
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type EnetpulseResultReferee struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
ResultFk string `json:"result_fk"`
|
||||||
|
RefereeFk pgtype.Text `json:"referee_fk"`
|
||||||
|
Assistant1RefereeFk pgtype.Text `json:"assistant1_referee_fk"`
|
||||||
|
Assistant2RefereeFk pgtype.Text `json:"assistant2_referee_fk"`
|
||||||
|
FourthRefereeFk pgtype.Text `json:"fourth_referee_fk"`
|
||||||
|
Var1RefereeFk pgtype.Text `json:"var1_referee_fk"`
|
||||||
|
Var2RefereeFk pgtype.Text `json:"var2_referee_fk"`
|
||||||
|
LastUpdatedAt pgtype.Timestamptz `json:"last_updated_at"`
|
||||||
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||||
|
}
|
||||||
|
|
||||||
type EnetpulseSport struct {
|
type EnetpulseSport struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
SportID string `json:"sport_id"`
|
SportID string `json:"sport_id"`
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ var (
|
||||||
ErrInvalidAtlasBaseUrl = errors.New("Atlas Base URL is invalid")
|
ErrInvalidAtlasBaseUrl = errors.New("Atlas Base URL is invalid")
|
||||||
ErrInvalidAtlasOperatorID = errors.New("Atlas operator ID is invalid")
|
ErrInvalidAtlasOperatorID = errors.New("Atlas operator ID is invalid")
|
||||||
ErrInvalidAtlasSecretKey = errors.New("Atlas secret key is invalid")
|
ErrInvalidAtlasSecretKey = errors.New("Atlas secret key is invalid")
|
||||||
ErrInvalidAtlasBrandID = errors.New("Atlas brand ID is invalid")
|
ErrInvalidAtlasBrandID = errors.New("Atlas brand ID is invalid")
|
||||||
ErrInvalidAtlasPartnerID = errors.New("Atlas Partner ID is invalid")
|
ErrInvalidAtlasPartnerID = errors.New("Atlas Partner ID is invalid")
|
||||||
|
|
||||||
ErrMissingResendApiKey = errors.New("missing Resend Api key")
|
ErrMissingResendApiKey = errors.New("missing Resend Api key")
|
||||||
|
|
@ -46,8 +46,9 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
type EnetPulseConfig struct {
|
type EnetPulseConfig struct {
|
||||||
UserName string `mapstructure:"username"` // "https://api.aleaplay.com"
|
UserName string `mapstructure:"username"`
|
||||||
Token string `mapstructure:"token"` // Your operator ID with Alea
|
Token string `mapstructure:"token"`
|
||||||
|
ProviderID string `mapstructure:"provider_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AleaPlayConfig struct {
|
type AleaPlayConfig struct {
|
||||||
|
|
@ -188,6 +189,7 @@ func (c *Config) loadEnv() error {
|
||||||
|
|
||||||
c.EnetPulseConfig.Token = os.Getenv("ENETPULSE_TOKEN")
|
c.EnetPulseConfig.Token = os.Getenv("ENETPULSE_TOKEN")
|
||||||
c.EnetPulseConfig.UserName = os.Getenv("ENETPULSE_USERNAME")
|
c.EnetPulseConfig.UserName = os.Getenv("ENETPULSE_USERNAME")
|
||||||
|
c.EnetPulseConfig.ProviderID = os.Getenv("ENETPULSE_PROVIDER_ID")
|
||||||
|
|
||||||
c.CHAPA_TRANSFER_TYPE = os.Getenv("CHAPA_TRANSFER_TYPE")
|
c.CHAPA_TRANSFER_TYPE = os.Getenv("CHAPA_TRANSFER_TYPE")
|
||||||
c.CHAPA_PAYMENT_TYPE = os.Getenv("CHAPA_PAYMENT_TYPE")
|
c.CHAPA_PAYMENT_TYPE = os.Getenv("CHAPA_PAYMENT_TYPE")
|
||||||
|
|
@ -427,34 +429,34 @@ func (c *Config) loadEnv() error {
|
||||||
Platform: popOKPlatform,
|
Platform: popOKPlatform,
|
||||||
}
|
}
|
||||||
|
|
||||||
AtlasBaseUrl := os.Getenv("ATLAS_BASE_URL")
|
// AtlasBaseUrl := os.Getenv("ATLAS_BASE_URL")
|
||||||
if AtlasBaseUrl == "" {
|
// if AtlasBaseUrl == "" {
|
||||||
return ErrInvalidAtlasBaseUrl
|
// return ErrInvalidAtlasBaseUrl
|
||||||
}
|
// }
|
||||||
AtlasSecretKey := os.Getenv("ATLAS_SECRET_KEY")
|
// AtlasSecretKey := os.Getenv("ATLAS_SECRET_KEY")
|
||||||
if AtlasSecretKey == "" {
|
// if AtlasSecretKey == "" {
|
||||||
return ErrInvalidAtlasSecretKey
|
// return ErrInvalidAtlasSecretKey
|
||||||
}
|
// }
|
||||||
AtlasBrandID := os.Getenv("ATLAS_BRAND_ID")
|
// AtlasBrandID := os.Getenv("ATLAS_BRAND_ID")
|
||||||
if AtlasBrandID == "" {
|
// if AtlasBrandID == "" {
|
||||||
return ErrInvalidAtlasBrandID
|
// return ErrInvalidAtlasBrandID
|
||||||
}
|
// }
|
||||||
AtlasPartnerID := os.Getenv("ATLAS_PARTNER_ID")
|
// AtlasPartnerID := os.Getenv("ATLAS_PARTNER_ID")
|
||||||
if AtlasPartnerID == "" {
|
// if AtlasPartnerID == "" {
|
||||||
return ErrInvalidAtlasPartnerID
|
// return ErrInvalidAtlasPartnerID
|
||||||
}
|
// }
|
||||||
AtlasOperatorID := os.Getenv("ATLAS_OPERATOR_ID")
|
// AtlasOperatorID := os.Getenv("ATLAS_OPERATOR_ID")
|
||||||
if AtlasOperatorID == "" {
|
// if AtlasOperatorID == "" {
|
||||||
return ErrInvalidAtlasOperatorID
|
// return ErrInvalidAtlasOperatorID
|
||||||
}
|
// }
|
||||||
|
|
||||||
c.Atlas = AtlasConfig{
|
// c.Atlas = AtlasConfig{
|
||||||
BaseURL: AtlasBaseUrl,
|
// BaseURL: AtlasBaseUrl,
|
||||||
SecretKey: AtlasSecretKey,
|
// SecretKey: AtlasSecretKey,
|
||||||
CasinoID: AtlasBrandID,
|
// CasinoID: AtlasBrandID,
|
||||||
PartnerID: AtlasPartnerID,
|
// PartnerID: AtlasPartnerID,
|
||||||
OperatorID: AtlasOperatorID,
|
// OperatorID: AtlasOperatorID,
|
||||||
}
|
// }
|
||||||
|
|
||||||
betToken := os.Getenv("BET365_TOKEN")
|
betToken := os.Getenv("BET365_TOKEN")
|
||||||
if betToken == "" {
|
if betToken == "" {
|
||||||
|
|
|
||||||
|
|
@ -462,3 +462,209 @@ type CreateEnetpulseTournamentStage struct {
|
||||||
CountryName string `json:"country_name"` // country name from API
|
CountryName string `json:"country_name"` // country name from API
|
||||||
Status int `json:"status"` // active/inactive
|
Status int `json:"status"` // active/inactive
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For insertion
|
||||||
|
type CreateEnetpulseFixture struct {
|
||||||
|
FixtureID string
|
||||||
|
Name string
|
||||||
|
SportFK string
|
||||||
|
TournamentFK string
|
||||||
|
TournamentTemplateFK string
|
||||||
|
TournamentStageFK string
|
||||||
|
TournamentStageName string
|
||||||
|
TournamentName string
|
||||||
|
TournamentTemplateName string
|
||||||
|
SportName string
|
||||||
|
Gender string
|
||||||
|
StartDate time.Time
|
||||||
|
StatusType string
|
||||||
|
StatusDescFK string
|
||||||
|
RoundTypeFK string
|
||||||
|
UpdatesCount int
|
||||||
|
LastUpdatedAt time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
// Full domain model
|
||||||
|
type EnetpulseFixture struct {
|
||||||
|
FixtureID string
|
||||||
|
Name string
|
||||||
|
SportFK string
|
||||||
|
TournamentFK string
|
||||||
|
TournamentTemplateFK string
|
||||||
|
TournamentStageFK string
|
||||||
|
TournamentStageName string
|
||||||
|
TournamentName string
|
||||||
|
TournamentTemplateName string
|
||||||
|
SportName string
|
||||||
|
Gender string
|
||||||
|
StartDate time.Time
|
||||||
|
StatusType string
|
||||||
|
StatusDescFK string
|
||||||
|
RoundTypeFK string
|
||||||
|
UpdatesCount int
|
||||||
|
LastUpdatedAt time.Time
|
||||||
|
CreatedAt time.Time
|
||||||
|
UpdatedAt time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateEnetpulseResult struct {
|
||||||
|
ResultID string `json:"result_id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
SportFK string `json:"sport_fk"`
|
||||||
|
TournamentFK string `json:"tournament_fk"`
|
||||||
|
TournamentTemplateFK string `json:"tournament_template_fk"`
|
||||||
|
TournamentStageFK string `json:"tournament_stage_fk"`
|
||||||
|
TournamentStageName string `json:"tournament_stage_name"`
|
||||||
|
TournamentName string `json:"tournament_name"`
|
||||||
|
TournamentTemplateName string `json:"tournament_template_name"`
|
||||||
|
SportName string `json:"sport_name"`
|
||||||
|
StartDate time.Time `json:"start_date"`
|
||||||
|
StatusType string `json:"status_type"`
|
||||||
|
StatusDescFK string `json:"status_desc_fk"`
|
||||||
|
RoundTypeFK string `json:"round_type_fk"`
|
||||||
|
UpdatesCount int32 `json:"updates_count"`
|
||||||
|
LastUpdatedAt time.Time `json:"last_updated_at"`
|
||||||
|
|
||||||
|
// Optional metadata
|
||||||
|
Round string `json:"round"`
|
||||||
|
Live string `json:"live"`
|
||||||
|
VenueName string `json:"venue_name"`
|
||||||
|
LivestatsPlus string `json:"livestats_plus"`
|
||||||
|
LivestatsType string `json:"livestats_type"`
|
||||||
|
Commentary string `json:"commentary"`
|
||||||
|
LineupConfirmed bool `json:"lineup_confirmed"`
|
||||||
|
Verified bool `json:"verified"`
|
||||||
|
Spectators int32 `json:"spectators"`
|
||||||
|
|
||||||
|
// Time-related metadata
|
||||||
|
GameStarted *time.Time `json:"game_started"`
|
||||||
|
FirstHalfEnded *time.Time `json:"first_half_ended"`
|
||||||
|
SecondHalfStarted *time.Time `json:"second_half_started"`
|
||||||
|
SecondHalfEnded *time.Time `json:"second_half_ended"`
|
||||||
|
GameEnded *time.Time `json:"game_ended"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ✅ Used for reading result records
|
||||||
|
type EnetpulseResult struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
ResultID string `json:"result_id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
SportFK string `json:"sport_fk"`
|
||||||
|
TournamentFK string `json:"tournament_fk"`
|
||||||
|
TournamentTemplateFK string `json:"tournament_template_fk"`
|
||||||
|
TournamentStageFK string `json:"tournament_stage_fk"`
|
||||||
|
TournamentStageName string `json:"tournament_stage_name"`
|
||||||
|
TournamentName string `json:"tournament_name"`
|
||||||
|
TournamentTemplateName string `json:"tournament_template_name"`
|
||||||
|
SportName string `json:"sport_name"`
|
||||||
|
StartDate time.Time `json:"start_date"`
|
||||||
|
StatusType string `json:"status_type"`
|
||||||
|
StatusDescFK string `json:"status_desc_fk"`
|
||||||
|
RoundTypeFK string `json:"round_type_fk"`
|
||||||
|
UpdatesCount int32 `json:"updates_count"`
|
||||||
|
LastUpdatedAt *time.Time `json:"last_updated_at"`
|
||||||
|
|
||||||
|
Round string `json:"round"`
|
||||||
|
Live string `json:"live"`
|
||||||
|
VenueName string `json:"venue_name"`
|
||||||
|
LivestatsPlus string `json:"livestats_plus"`
|
||||||
|
LivestatsType string `json:"livestats_type"`
|
||||||
|
Commentary string `json:"commentary"`
|
||||||
|
LineupConfirmed bool `json:"lineup_confirmed"`
|
||||||
|
Verified bool `json:"verified"`
|
||||||
|
Spectators int32 `json:"spectators"`
|
||||||
|
|
||||||
|
GameStarted *time.Time `json:"game_started"`
|
||||||
|
FirstHalfEnded *time.Time `json:"first_half_ended"`
|
||||||
|
SecondHalfStarted *time.Time `json:"second_half_started"`
|
||||||
|
SecondHalfEnded *time.Time `json:"second_half_ended"`
|
||||||
|
GameEnded *time.Time `json:"game_ended"`
|
||||||
|
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt *time.Time `json:"updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type EnetpulseOutcomeType struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
OutcomeTypeID string `json:"outcome_type_id"` // changed from int64 → string
|
||||||
|
Name string `json:"name"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
UpdatesCount int32 `json:"updates_count"`
|
||||||
|
LastUpdatedAt time.Time `json:"last_updated_at"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateEnetpulseOutcomeType represents the payload to create or update an outcome type.
|
||||||
|
type CreateEnetpulseOutcomeType struct {
|
||||||
|
OutcomeTypeID string `json:"outcome_type_id"` // changed from int64 → string
|
||||||
|
Name string `json:"name"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
UpdatesCount int32 `json:"updates_count"`
|
||||||
|
LastUpdatedAt time.Time `json:"last_updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type EnetpulsePreodds struct {
|
||||||
|
PreoddsID string `json:"preodds_id"`
|
||||||
|
EventFK string `json:"event_fk"`
|
||||||
|
OutcomeTypeFK string `json:"outcome_type_fk"`
|
||||||
|
OutcomeScopeFK string `json:"outcome_scope_fk"`
|
||||||
|
OutcomeSubtypeFK string `json:"outcome_subtype_fk"`
|
||||||
|
EventParticipantNumber int `json:"event_participant_number"`
|
||||||
|
IParam string `json:"iparam"`
|
||||||
|
IParam2 string `json:"iparam2"`
|
||||||
|
DParam string `json:"dparam"`
|
||||||
|
DParam2 string `json:"dparam2"`
|
||||||
|
SParam string `json:"sparam"`
|
||||||
|
UpdatesCount int `json:"updates_count"`
|
||||||
|
LastUpdatedAt time.Time `json:"last_updated_at"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateEnetpulsePreodds is used when inserting a new preodds record
|
||||||
|
type CreateEnetpulsePreodds struct {
|
||||||
|
PreoddsID string `json:"preodds_id"`
|
||||||
|
EventFK string `json:"event_fk"`
|
||||||
|
OutcomeTypeFK string `json:"outcome_type_fk"`
|
||||||
|
OutcomeScopeFK string `json:"outcome_scope_fk"`
|
||||||
|
OutcomeSubtypeFK string `json:"outcome_subtype_fk"`
|
||||||
|
EventParticipantNumber int `json:"event_participant_number"`
|
||||||
|
IParam string `json:"iparam"`
|
||||||
|
IParam2 string `json:"iparam2"`
|
||||||
|
DParam string `json:"dparam"`
|
||||||
|
DParam2 string `json:"dparam2"`
|
||||||
|
SParam string `json:"sparam"`
|
||||||
|
UpdatesCount int `json:"updates_count"`
|
||||||
|
LastUpdatedAt time.Time `json:"last_updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateEnetpulsePreoddsBettingOffer struct {
|
||||||
|
BettingOfferID string
|
||||||
|
PreoddsFK string
|
||||||
|
BettingOfferStatusFK int32
|
||||||
|
OddsProviderFK int32
|
||||||
|
Odds float64
|
||||||
|
OddsOld float64
|
||||||
|
Active string
|
||||||
|
CouponKey string
|
||||||
|
UpdatesCount int
|
||||||
|
LastUpdatedAt time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnetpulsePreoddsBettingOffer represents the DB record of a betting offer
|
||||||
|
type EnetpulsePreoddsBettingOffer struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
BettingOfferID string `json:"betting_offer_id"`
|
||||||
|
PreoddsFK string `json:"preodds_fk"`
|
||||||
|
BettingOfferStatusFK int32 `json:"betting_offer_status_fk"`
|
||||||
|
OddsProviderFK int32 `json:"odds_provider_fk"`
|
||||||
|
Odds float64 `json:"odds"`
|
||||||
|
OddsOld float64 `json:"odds_old"`
|
||||||
|
Active string `json:"active"`
|
||||||
|
CouponKey string `json:"coupon_key"`
|
||||||
|
UpdatesCount int `json:"updates_count"`
|
||||||
|
LastUpdatedAt time.Time `json:"last_updated_at"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,9 @@ package repository
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
|
"math/big"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
dbgen "github.com/SamuelTariku/FortuneBet-Backend/gen/db"
|
dbgen "github.com/SamuelTariku/FortuneBet-Backend/gen/db"
|
||||||
|
|
@ -140,6 +143,165 @@ func (s *Store) GetTournamentStagesByTournamentFK(ctx context.Context, tournamen
|
||||||
return stages, nil
|
return stages, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a new fixture
|
||||||
|
func (s *Store) CreateEnetpulseFixture(
|
||||||
|
ctx context.Context,
|
||||||
|
fixture domain.CreateEnetpulseFixture,
|
||||||
|
) (domain.EnetpulseFixture, error) {
|
||||||
|
// Convert domain model to DB params (sqlc-generated struct or parameters)
|
||||||
|
dbFixture, err := s.queries.CreateEnetpulseFixture(
|
||||||
|
ctx,
|
||||||
|
ConvertCreateEnetpulseFixture(fixture), // your converter
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return domain.EnetpulseFixture{}, err
|
||||||
|
}
|
||||||
|
return ConvertDBEnetpulseFixture(dbFixture), nil // convert DB row to domain
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch all fixtures
|
||||||
|
func (s *Store) GetAllEnetpulseFixtures(ctx context.Context) ([]domain.EnetpulseFixture, error) {
|
||||||
|
dbFixtures, err := s.queries.GetAllEnetpulseFixtures(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var fixtures []domain.EnetpulseFixture
|
||||||
|
for _, dbFixture := range dbFixtures {
|
||||||
|
fixtures = append(fixtures, ConvertDBEnetpulseFixture(dbFixture))
|
||||||
|
}
|
||||||
|
|
||||||
|
return fixtures, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Store) CreateEnetpulseResult(
|
||||||
|
ctx context.Context,
|
||||||
|
result domain.CreateEnetpulseResult,
|
||||||
|
) (domain.EnetpulseResult, error) {
|
||||||
|
dbResult, err := s.queries.CreateEnetpulseResult(
|
||||||
|
ctx,
|
||||||
|
ConvertCreateEnetpulseResult(result),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return domain.EnetpulseResult{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return ConvertDBEnetpulseResult(dbResult), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAllEnetpulseResults retrieves all Enetpulse results.
|
||||||
|
func (s *Store) GetAllEnetpulseResults(ctx context.Context) ([]domain.EnetpulseResult, error) {
|
||||||
|
dbResults, err := s.queries.GetAllEnetpulseResults(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
results := make([]domain.EnetpulseResult, 0, len(dbResults))
|
||||||
|
for _, dbR := range dbResults {
|
||||||
|
results = append(results, ConvertDBEnetpulseResult(dbR))
|
||||||
|
}
|
||||||
|
|
||||||
|
return results, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateEnetpulseOutcomeType inserts or updates an EnetPulse outcome type record.
|
||||||
|
func (s *Store) CreateEnetpulseOutcomeType(
|
||||||
|
ctx context.Context,
|
||||||
|
outcomeType domain.CreateEnetpulseOutcomeType,
|
||||||
|
) (domain.EnetpulseOutcomeType, error) {
|
||||||
|
dbOutcome, err := s.queries.CreateEnetpulseOutcomeType(
|
||||||
|
ctx,
|
||||||
|
ConvertCreateEnetpulseOutcomeType(outcomeType),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return domain.EnetpulseOutcomeType{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return ConvertDBEnetpulseOutcomeType(dbOutcome), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAllEnetpulseOutcomeTypes retrieves all outcome types.
|
||||||
|
func (s *Store) GetAllEnetpulseOutcomeTypes(ctx context.Context) ([]domain.EnetpulseOutcomeType, error) {
|
||||||
|
dbOutcomes, err := s.queries.GetAllEnetpulseOutcomeTypes(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
outcomes := make([]domain.EnetpulseOutcomeType, 0, len(dbOutcomes))
|
||||||
|
for _, dbO := range dbOutcomes {
|
||||||
|
outcomes = append(outcomes, ConvertDBEnetpulseOutcomeType(dbO))
|
||||||
|
}
|
||||||
|
|
||||||
|
return outcomes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateEnetpulsePreodds inserts or updates a preodds record.
|
||||||
|
func (s *Store) CreateEnetpulsePreodds(
|
||||||
|
ctx context.Context,
|
||||||
|
preodds domain.CreateEnetpulsePreodds,
|
||||||
|
) (domain.EnetpulsePreodds, error) {
|
||||||
|
|
||||||
|
// Convert domain to DB params
|
||||||
|
params, err := ConvertCreateEnetpulsePreodds(preodds)
|
||||||
|
if err != nil {
|
||||||
|
return domain.EnetpulsePreodds{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert into DB
|
||||||
|
dbPreodds, err := s.queries.CreateEnetpulsePreodds(ctx, params)
|
||||||
|
if err != nil {
|
||||||
|
return domain.EnetpulsePreodds{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return ConvertDBEnetpulsePreodds(dbPreodds), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAllEnetpulsePreodds retrieves all preodds records.
|
||||||
|
func (s *Store) GetAllEnetpulsePreodds(ctx context.Context) ([]domain.EnetpulsePreodds, error) {
|
||||||
|
dbPreodds, err := s.queries.GetAllEnetpulsePreodds(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
preodds := make([]domain.EnetpulsePreodds, 0, len(dbPreodds))
|
||||||
|
for _, dbP := range dbPreodds {
|
||||||
|
preodds = append(preodds, ConvertDBEnetpulsePreodds(dbP))
|
||||||
|
}
|
||||||
|
|
||||||
|
return preodds, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateEnetpulsePreoddsBettingOffer inserts or updates a betting offer
|
||||||
|
func (s *Store) CreateEnetpulsePreoddsBettingOffer(
|
||||||
|
ctx context.Context,
|
||||||
|
bettingOffer domain.CreateEnetpulsePreoddsBettingOffer,
|
||||||
|
) (domain.EnetpulsePreoddsBettingOffer, error) {
|
||||||
|
|
||||||
|
params := ConvertCreateEnetpulsePreoddsBettingOffer(bettingOffer)
|
||||||
|
|
||||||
|
dbOffer, err := s.queries.CreateEnetpulsePreoddsBettingOffer(ctx, params)
|
||||||
|
if err != nil {
|
||||||
|
return domain.EnetpulsePreoddsBettingOffer{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return ConvertDBEnetpulsePreoddsBettingOffer(dbOffer), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAllEnetpulsePreoddsBettingOffers retrieves all betting offers
|
||||||
|
func (s *Store) GetAllEnetpulsePreoddsBettingOffers(ctx context.Context) ([]domain.EnetpulsePreoddsBettingOffer, error) {
|
||||||
|
dbOffers, err := s.queries.GetAllEnetpulsePreoddsBettingOffers(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
offers := make([]domain.EnetpulsePreoddsBettingOffer, 0, len(dbOffers))
|
||||||
|
for _, dbO := range dbOffers {
|
||||||
|
offers = append(offers, ConvertDBEnetpulsePreoddsBettingOffer(dbO))
|
||||||
|
}
|
||||||
|
|
||||||
|
return offers, nil
|
||||||
|
}
|
||||||
|
|
||||||
// func ConvertCreateEnetpulseTournamentStage(stage domain.CreateEnetpulseTournamentStage) dbgen.EnetpulseTournamentStage {
|
// func ConvertCreateEnetpulseTournamentStage(stage domain.CreateEnetpulseTournamentStage) dbgen.EnetpulseTournamentStage {
|
||||||
// return dbgen.EnetpulseTournamentStage{
|
// return dbgen.EnetpulseTournamentStage{
|
||||||
// StageID: stage.StageID,
|
// StageID: stage.StageID,
|
||||||
|
|
@ -157,6 +319,54 @@ func (s *Store) GetTournamentStagesByTournamentFK(ctx context.Context, tournamen
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// ConvertCreateEnetpulseFixture converts the domain model to the SQLC params struct.
|
||||||
|
func ConvertCreateEnetpulseFixture(f domain.CreateEnetpulseFixture) dbgen.CreateEnetpulseFixtureParams {
|
||||||
|
return dbgen.CreateEnetpulseFixtureParams{
|
||||||
|
FixtureID: f.FixtureID,
|
||||||
|
Name: f.Name,
|
||||||
|
SportFk: f.SportFK,
|
||||||
|
TournamentFk: pgtype.Text{String: f.TournamentFK, Valid: f.TournamentFK != ""},
|
||||||
|
TournamentTemplateFk: pgtype.Text{String: f.TournamentTemplateFK, Valid: f.TournamentTemplateFK != ""},
|
||||||
|
TournamentStageFk: pgtype.Text{String: f.TournamentStageFK, Valid: f.TournamentStageFK != ""},
|
||||||
|
TournamentStageName: pgtype.Text{String: f.TournamentStageName, Valid: f.TournamentStageName != ""},
|
||||||
|
TournamentName: pgtype.Text{String: f.TournamentName, Valid: f.TournamentName != ""},
|
||||||
|
TournamentTemplateName: pgtype.Text{String: f.TournamentTemplateName, Valid: f.TournamentTemplateName != ""},
|
||||||
|
SportName: pgtype.Text{String: f.SportName, Valid: f.SportName != ""},
|
||||||
|
Gender: pgtype.Text{String: f.Gender, Valid: f.Gender != ""},
|
||||||
|
StartDate: pgtype.Timestamptz{Time: f.StartDate, Valid: !f.StartDate.IsZero()},
|
||||||
|
StatusType: pgtype.Text{String: f.StatusType, Valid: f.StatusType != ""},
|
||||||
|
StatusDescFk: pgtype.Text{String: f.StatusDescFK, Valid: f.StatusDescFK != ""},
|
||||||
|
RoundTypeFk: pgtype.Text{String: f.RoundTypeFK, Valid: f.RoundTypeFK != ""},
|
||||||
|
UpdatesCount: pgtype.Int4{Int32: int32(f.UpdatesCount), Valid: true},
|
||||||
|
LastUpdatedAt: pgtype.Timestamptz{Time: f.LastUpdatedAt, Valid: !f.LastUpdatedAt.IsZero()},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConvertDBEnetpulseFixture converts the DB row to the domain model.
|
||||||
|
func ConvertDBEnetpulseFixture(dbF dbgen.EnetpulseFixture) domain.EnetpulseFixture {
|
||||||
|
return domain.EnetpulseFixture{
|
||||||
|
FixtureID: dbF.FixtureID,
|
||||||
|
Name: dbF.Name,
|
||||||
|
SportFK: dbF.SportFk,
|
||||||
|
TournamentFK: dbF.TournamentFk.String,
|
||||||
|
TournamentTemplateFK: dbF.TournamentTemplateFk.String,
|
||||||
|
TournamentStageFK: dbF.TournamentStageFk.String,
|
||||||
|
TournamentStageName: dbF.TournamentStageName.String,
|
||||||
|
TournamentName: dbF.TournamentName.String,
|
||||||
|
TournamentTemplateName: dbF.TournamentTemplateName.String,
|
||||||
|
SportName: dbF.SportName.String,
|
||||||
|
Gender: dbF.Gender.String,
|
||||||
|
StartDate: dbF.StartDate.Time,
|
||||||
|
StatusType: dbF.StatusType.String,
|
||||||
|
StatusDescFK: dbF.StatusDescFk.String,
|
||||||
|
RoundTypeFK: dbF.RoundTypeFk.String,
|
||||||
|
UpdatesCount: int(dbF.UpdatesCount.Int32),
|
||||||
|
LastUpdatedAt: dbF.LastUpdatedAt.Time,
|
||||||
|
CreatedAt: dbF.CreatedAt.Time,
|
||||||
|
UpdatedAt: dbF.UpdatedAt.Time,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func ConvertCreateEnetpulseTournamentStage(stage domain.CreateEnetpulseTournamentStage) dbgen.CreateEnetpulseTournamentStageParams {
|
func ConvertCreateEnetpulseTournamentStage(stage domain.CreateEnetpulseTournamentStage) dbgen.CreateEnetpulseTournamentStageParams {
|
||||||
return dbgen.CreateEnetpulseTournamentStageParams{
|
return dbgen.CreateEnetpulseTournamentStageParams{
|
||||||
StageID: stage.StageID,
|
StageID: stage.StageID,
|
||||||
|
|
@ -321,3 +531,222 @@ func ConvertDBEnetpulseTournament(dbT dbgen.EnetpulseTournament) domain.Enetpuls
|
||||||
}(),
|
}(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ConvertCreateEnetpulseResult(input domain.CreateEnetpulseResult) dbgen.CreateEnetpulseResultParams {
|
||||||
|
return dbgen.CreateEnetpulseResultParams{
|
||||||
|
ResultID: input.ResultID,
|
||||||
|
Name: input.Name,
|
||||||
|
SportFk: input.SportFK,
|
||||||
|
TournamentFk: pgtype.Text{String: input.TournamentFK, Valid: input.TournamentFK != ""},
|
||||||
|
TournamentTemplateFk: pgtype.Text{String: input.TournamentTemplateFK, Valid: input.TournamentTemplateFK != ""},
|
||||||
|
TournamentStageFk: pgtype.Text{String: input.TournamentStageFK, Valid: input.TournamentStageFK != ""},
|
||||||
|
TournamentStageName: pgtype.Text{String: input.TournamentStageName, Valid: input.TournamentStageName != ""},
|
||||||
|
TournamentName: pgtype.Text{String: input.TournamentName, Valid: input.TournamentName != ""},
|
||||||
|
TournamentTemplateName: pgtype.Text{String: input.TournamentTemplateName, Valid: input.TournamentTemplateName != ""},
|
||||||
|
SportName: pgtype.Text{String: input.SportName, Valid: input.SportName != ""},
|
||||||
|
StartDate: pgtype.Timestamptz{Time: input.StartDate, Valid: !input.StartDate.IsZero()},
|
||||||
|
StatusType: pgtype.Text{String: input.StatusType, Valid: input.StatusType != ""},
|
||||||
|
StatusDescFk: pgtype.Text{String: input.StatusDescFK, Valid: input.StatusDescFK != ""},
|
||||||
|
RoundTypeFk: pgtype.Text{String: input.RoundTypeFK, Valid: input.RoundTypeFK != ""},
|
||||||
|
UpdatesCount: pgtype.Int4{Int32: int32(input.UpdatesCount), Valid: true},
|
||||||
|
LastUpdatedAt: pgtype.Timestamptz{Time: input.LastUpdatedAt, Valid: !input.LastUpdatedAt.IsZero()},
|
||||||
|
Round: pgtype.Text{String: input.Round, Valid: input.Round != ""},
|
||||||
|
Live: pgtype.Text{String: input.Live, Valid: input.Live != ""},
|
||||||
|
VenueName: pgtype.Text{String: input.VenueName, Valid: input.VenueName != ""},
|
||||||
|
LivestatsPlus: pgtype.Text{String: input.LivestatsPlus, Valid: input.LivestatsPlus != ""},
|
||||||
|
LivestatsType: pgtype.Text{String: input.LivestatsType, Valid: input.LivestatsType != ""},
|
||||||
|
Commentary: pgtype.Text{String: input.Commentary, Valid: input.Commentary != ""},
|
||||||
|
LineupConfirmed: pgtype.Bool{Bool: input.LineupConfirmed, Valid: true},
|
||||||
|
Verified: pgtype.Bool{Bool: input.Verified, Valid: true},
|
||||||
|
Spectators: pgtype.Int4{Int32: int32(input.Spectators), Valid: true},
|
||||||
|
GameStarted: pgtype.Timestamptz{Time: *input.GameStarted, Valid: !input.GameStarted.IsZero()},
|
||||||
|
FirstHalfEnded: pgtype.Timestamptz{Time: *input.FirstHalfEnded, Valid: !input.FirstHalfEnded.IsZero()},
|
||||||
|
SecondHalfStarted: pgtype.Timestamptz{Time: *input.SecondHalfStarted, Valid: !input.SecondHalfStarted.IsZero()},
|
||||||
|
SecondHalfEnded: pgtype.Timestamptz{Time: *input.SecondHalfEnded, Valid: !input.SecondHalfEnded.IsZero()},
|
||||||
|
GameEnded: pgtype.Timestamptz{Time: *input.GameEnded, Valid: !input.GameEnded.IsZero()},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConvertDBEnetpulseResult maps SQLC result → domain model
|
||||||
|
func ConvertDBEnetpulseResult(db dbgen.EnetpulseResult) domain.EnetpulseResult {
|
||||||
|
return domain.EnetpulseResult{
|
||||||
|
ID: db.ID,
|
||||||
|
ResultID: db.ResultID,
|
||||||
|
Name: db.Name,
|
||||||
|
SportFK: db.SportFk,
|
||||||
|
TournamentFK: db.TournamentFk.String,
|
||||||
|
TournamentTemplateFK: db.TournamentTemplateFk.String,
|
||||||
|
TournamentStageFK: db.TournamentStageFk.String,
|
||||||
|
TournamentStageName: db.TournamentStageName.String,
|
||||||
|
TournamentName: db.TournamentName.String,
|
||||||
|
TournamentTemplateName: db.TournamentTemplateName.String,
|
||||||
|
SportName: db.SportName.String,
|
||||||
|
StartDate: db.StartDate.Time,
|
||||||
|
StatusType: db.StatusType.String,
|
||||||
|
StatusDescFK: db.StatusDescFk.String,
|
||||||
|
RoundTypeFK: db.RoundTypeFk.String,
|
||||||
|
UpdatesCount: db.UpdatesCount.Int32,
|
||||||
|
LastUpdatedAt: &db.LastUpdatedAt.Time,
|
||||||
|
Round: db.Round.String,
|
||||||
|
Live: db.Live.String,
|
||||||
|
VenueName: db.VenueName.String,
|
||||||
|
LivestatsPlus: db.LivestatsPlus.String,
|
||||||
|
LivestatsType: db.LivestatsType.String,
|
||||||
|
Commentary: db.Commentary.String,
|
||||||
|
LineupConfirmed: db.LineupConfirmed.Bool,
|
||||||
|
Verified: db.Verified.Bool,
|
||||||
|
Spectators: db.Spectators.Int32,
|
||||||
|
GameStarted: &db.GameStarted.Time,
|
||||||
|
FirstHalfEnded: &db.FirstHalfEnded.Time,
|
||||||
|
SecondHalfStarted: &db.SecondHalfStarted.Time,
|
||||||
|
SecondHalfEnded: &db.SecondHalfEnded.Time,
|
||||||
|
GameEnded: &db.GameEnded.Time,
|
||||||
|
CreatedAt: db.CreatedAt.Time,
|
||||||
|
UpdatedAt: &db.UpdatedAt.Time,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConvertCreateEnetpulseOutcomeType converts the domain struct to SQLC params.
|
||||||
|
func ConvertCreateEnetpulseOutcomeType(o domain.CreateEnetpulseOutcomeType) dbgen.CreateEnetpulseOutcomeTypeParams {
|
||||||
|
return dbgen.CreateEnetpulseOutcomeTypeParams{
|
||||||
|
OutcomeTypeID: o.OutcomeTypeID,
|
||||||
|
Name: o.Name,
|
||||||
|
Description: pgtype.Text{String: o.Description, Valid: o.Description != ""}, // TODO: thiso.Description,
|
||||||
|
UpdatesCount: pgtype.Int4{Int32: int32(o.UpdatesCount), Valid: true},
|
||||||
|
LastUpdatedAt: pgtype.Timestamptz{Time: o.LastUpdatedAt, Valid: !o.LastUpdatedAt.IsZero()},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConvertDBEnetpulseOutcomeType converts SQLC DB model to domain model.
|
||||||
|
func ConvertDBEnetpulseOutcomeType(dbO dbgen.EnetpulseOutcomeType) domain.EnetpulseOutcomeType {
|
||||||
|
return domain.EnetpulseOutcomeType{
|
||||||
|
ID: dbO.ID,
|
||||||
|
OutcomeTypeID: dbO.OutcomeTypeID,
|
||||||
|
Name: dbO.Name,
|
||||||
|
Description: dbO.Description.String,
|
||||||
|
UpdatesCount: dbO.UpdatesCount.Int32,
|
||||||
|
LastUpdatedAt: dbO.LastUpdatedAt.Time,
|
||||||
|
CreatedAt: dbO.CreatedAt.Time,
|
||||||
|
UpdatedAt: dbO.UpdatedAt.Time,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func ConvertCreateEnetpulsePreodds(p domain.CreateEnetpulsePreodds) (dbgen.CreateEnetpulsePreoddsParams, error) {
|
||||||
|
eventFK, err := strconv.ParseInt(p.EventFK, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return dbgen.CreateEnetpulsePreoddsParams{}, fmt.Errorf("invalid EventFK: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
outcomeTypeFK, err := strconv.ParseInt(p.OutcomeTypeFK, 10, 32)
|
||||||
|
if err != nil {
|
||||||
|
return dbgen.CreateEnetpulsePreoddsParams{}, fmt.Errorf("invalid OutcomeTypeFK: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
outcomeScopeFK, err := strconv.ParseInt(p.OutcomeScopeFK, 10, 32)
|
||||||
|
if err != nil {
|
||||||
|
return dbgen.CreateEnetpulsePreoddsParams{}, fmt.Errorf("invalid OutcomeScopeFK: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
outcomeSubtypeFK, err := strconv.ParseInt(p.OutcomeSubtypeFK, 10, 32)
|
||||||
|
if err != nil {
|
||||||
|
return dbgen.CreateEnetpulsePreoddsParams{}, fmt.Errorf("invalid OutcomeSubtypeFK: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return dbgen.CreateEnetpulsePreoddsParams{
|
||||||
|
PreoddsID: p.PreoddsID,
|
||||||
|
EventFk: eventFK,
|
||||||
|
OutcomeTypeFk: pgtype.Int4{Int32: int32(outcomeTypeFK), Valid: true},
|
||||||
|
OutcomeScopeFk: pgtype.Int4{Int32: int32(outcomeScopeFK), Valid: true},
|
||||||
|
OutcomeSubtypeFk: pgtype.Int4{Int32: int32(outcomeSubtypeFK), Valid: true},
|
||||||
|
EventParticipantNumber: pgtype.Int4{Int32: int32(p.EventParticipantNumber), Valid: true},
|
||||||
|
Iparam: pgtype.Text{String: p.IParam, Valid: p.IParam != ""},
|
||||||
|
Iparam2: pgtype.Text{String: p.IParam2, Valid: p.IParam2 != ""},
|
||||||
|
Dparam: pgtype.Text{String: p.DParam, Valid: p.DParam != ""},
|
||||||
|
Dparam2: pgtype.Text{String: p.DParam2, Valid: p.DParam2 != ""},
|
||||||
|
Sparam: pgtype.Text{String: p.SParam, Valid: p.SParam != ""},
|
||||||
|
UpdatesCount: pgtype.Int4{Int32: int32(p.UpdatesCount), Valid: true},
|
||||||
|
LastUpdatedAt: pgtype.Timestamptz{Time: p.LastUpdatedAt, Valid: !p.LastUpdatedAt.IsZero()},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func ConvertDBEnetpulsePreodds(dbP dbgen.EnetpulsePreodd) domain.EnetpulsePreodds {
|
||||||
|
return domain.EnetpulsePreodds{
|
||||||
|
PreoddsID: dbP.PreoddsID,
|
||||||
|
EventFK: fmt.Sprintf("%v", dbP.EventFk),
|
||||||
|
OutcomeTypeFK: fmt.Sprintf("%v", dbP.OutcomeTypeFk),
|
||||||
|
OutcomeScopeFK: fmt.Sprintf("%v", dbP.OutcomeScopeFk),
|
||||||
|
OutcomeSubtypeFK: fmt.Sprintf("%v", dbP.OutcomeSubtypeFk),
|
||||||
|
EventParticipantNumber: int(dbP.EventParticipantNumber.Int32),
|
||||||
|
IParam: dbP.Iparam.String,
|
||||||
|
IParam2: dbP.Iparam2.String,
|
||||||
|
DParam: dbP.Dparam.String,
|
||||||
|
DParam2: dbP.Dparam2.String,
|
||||||
|
SParam: dbP.Sparam.String,
|
||||||
|
UpdatesCount: int(dbP.UpdatesCount.Int32),
|
||||||
|
LastUpdatedAt: dbP.LastUpdatedAt.Time,
|
||||||
|
CreatedAt: dbP.CreatedAt.Time,
|
||||||
|
UpdatedAt: dbP.UpdatedAt.Time,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func ConvertCreateEnetpulsePreoddsBettingOffer(o domain.CreateEnetpulsePreoddsBettingOffer) dbgen.CreateEnetpulsePreoddsBettingOfferParams {
|
||||||
|
// Convert float64 to int64 with scale 2
|
||||||
|
oddsInt := big.NewInt(int64(math.Round(o.Odds * 100)))
|
||||||
|
oddsOldInt := big.NewInt(int64(math.Round(o.OddsOld * 100)))
|
||||||
|
|
||||||
|
return dbgen.CreateEnetpulsePreoddsBettingOfferParams{
|
||||||
|
BettingofferID: o.BettingOfferID,
|
||||||
|
PreoddsFk: o.PreoddsFK,
|
||||||
|
BettingofferStatusFk: pgtype.Int4{Int32: o.BettingOfferStatusFK, Valid: true},
|
||||||
|
OddsProviderFk: pgtype.Int4{Int32: o.OddsProviderFK, Valid: true},
|
||||||
|
Odds: pgtype.Numeric{
|
||||||
|
Int: oddsInt,
|
||||||
|
Exp: -2, // scale 2 decimal places
|
||||||
|
Valid: true,
|
||||||
|
},
|
||||||
|
OddsOld: pgtype.Numeric{
|
||||||
|
Int: oddsOldInt,
|
||||||
|
Exp: -2,
|
||||||
|
Valid: true,
|
||||||
|
},
|
||||||
|
Active: pgtype.Bool{Bool: o.Active == "yes", Valid: true},
|
||||||
|
CouponKey: pgtype.Text{
|
||||||
|
String: o.CouponKey,
|
||||||
|
Valid: o.CouponKey != "",
|
||||||
|
},
|
||||||
|
UpdatesCount: pgtype.Int4{Int32: int32(o.UpdatesCount), Valid: true},
|
||||||
|
LastUpdatedAt: pgtype.Timestamptz{Time: o.LastUpdatedAt, Valid: !o.LastUpdatedAt.IsZero()},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert DB result to domain struct
|
||||||
|
func ConvertDBEnetpulsePreoddsBettingOffer(o dbgen.EnetpulsePreoddsBettingoffer) domain.EnetpulsePreoddsBettingOffer {
|
||||||
|
var odds, oddsOld float64
|
||||||
|
if o.Odds.Valid {
|
||||||
|
odds, _ = o.Odds.Int.Float64() // Convert pgtype.Numeric to float64
|
||||||
|
}
|
||||||
|
if o.OddsOld.Valid {
|
||||||
|
oddsOld, _ = o.OddsOld.Int.Float64()
|
||||||
|
}
|
||||||
|
|
||||||
|
active := "no"
|
||||||
|
if o.Active.Valid && o.Active.Bool {
|
||||||
|
active = "yes"
|
||||||
|
}
|
||||||
|
|
||||||
|
return domain.EnetpulsePreoddsBettingOffer{
|
||||||
|
ID: o.ID,
|
||||||
|
BettingOfferID: o.BettingofferID,
|
||||||
|
PreoddsFK: o.PreoddsFk,
|
||||||
|
BettingOfferStatusFK: o.BettingofferStatusFk.Int32,
|
||||||
|
OddsProviderFK: o.OddsProviderFk.Int32,
|
||||||
|
Odds: odds,
|
||||||
|
OddsOld: oddsOld,
|
||||||
|
Active: active,
|
||||||
|
CouponKey: o.CouponKey.String,
|
||||||
|
UpdatesCount: int(o.UpdatesCount.Int32),
|
||||||
|
LastUpdatedAt: o.LastUpdatedAt.Time,
|
||||||
|
CreatedAt: o.CreatedAt.Time,
|
||||||
|
UpdatedAt: o.UpdatedAt.Time,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -84,9 +84,9 @@ func (s *ServiceImpl) ProcessBet365Odds(ctx context.Context) error {
|
||||||
Value: domain.STATUS_PENDING,
|
Value: domain.STATUS_PENDING,
|
||||||
Valid: true,
|
Valid: true,
|
||||||
},
|
},
|
||||||
Source: domain.ValidEventSource{
|
// Source: domain.ValidEventSource{
|
||||||
Value: domain.EVENT_SOURCE_BET365,
|
// Value: domain.EVENT_SOURCE_BET365,
|
||||||
},
|
// },
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.mongoLogger.Error(
|
s.mongoLogger.Error(
|
||||||
|
|
|
||||||
|
|
@ -236,10 +236,10 @@ func (s *Service) FetchB365ResultAndUpdateBets(ctx context.Context) error {
|
||||||
Value: time.Now(),
|
Value: time.Now(),
|
||||||
Valid: true,
|
Valid: true,
|
||||||
},
|
},
|
||||||
Source: domain.ValidEventSource{
|
// Source: domain.ValidEventSource{
|
||||||
Value: domain.EVENT_SOURCE_BET365,
|
// Value: domain.EVENT_SOURCE_BET365,
|
||||||
Valid: true,
|
// Valid: true,
|
||||||
},
|
// },
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -733,10 +733,10 @@ func (s *Service) CheckAndUpdateExpiredB365Events(ctx context.Context) (int64, e
|
||||||
Value: time.Now(),
|
Value: time.Now(),
|
||||||
Valid: true,
|
Valid: true,
|
||||||
},
|
},
|
||||||
Source: domain.ValidEventSource{
|
// Source: domain.ValidEventSource{
|
||||||
Value: domain.EVENT_SOURCE_BET365,
|
// Value: domain.EVENT_SOURCE_BET365,
|
||||||
Valid: true,
|
// Valid: true,
|
||||||
},
|
// },
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.mongoLogger.Error(
|
s.mongoLogger.Error(
|
||||||
|
|
@ -955,7 +955,7 @@ func (s *Service) GetBet365ResultForEvent(ctx context.Context, b365EventID strin
|
||||||
zap.String("b365EventID", b365EventID),
|
zap.String("b365EventID", b365EventID),
|
||||||
zap.Error(err),
|
zap.Error(err),
|
||||||
)
|
)
|
||||||
return json.RawMessage{}, nil, fmt.Errorf("invalid API response for event %d", b365EventID)
|
return json.RawMessage{}, nil, fmt.Errorf("invalid API response for event %s", b365EventID)
|
||||||
}
|
}
|
||||||
|
|
||||||
var commonResp domain.CommonResultResponse
|
var commonResp domain.CommonResultResponse
|
||||||
|
|
|
||||||
|
|
@ -252,60 +252,89 @@ func StartEnetPulseCron(enetPulseSvc *enetpulse.Service, mongoLogger *zap.Logger
|
||||||
task func()
|
task func()
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
spec: "0 0,10,20,30,40,50 * * * *", // Every 10 minutes
|
spec: "0 0 */2 * * *", // Every 2 hours
|
||||||
task: func() {
|
task: func() {
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
// 1️⃣ Sports
|
||||||
mongoLogger.Info("Began fetching and storing sports cron task")
|
mongoLogger.Info("Began fetching and storing sports cron task")
|
||||||
if err := enetPulseSvc.FetchAndStoreSports(context.Background()); err != nil {
|
if err := enetPulseSvc.FetchAndStoreSports(ctx); err != nil {
|
||||||
mongoLogger.Error("Failed to fetch and store sports",
|
mongoLogger.Error("Failed to fetch and store sports", zap.Error(err))
|
||||||
zap.Error(err),
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
mongoLogger.Info("Completed fetching and storing sports without errors")
|
mongoLogger.Info("✅ Completed fetching and storing sports")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2️⃣ Tournament Templates
|
||||||
mongoLogger.Info("Began fetching and storing tournament templates cron task")
|
mongoLogger.Info("Began fetching and storing tournament templates cron task")
|
||||||
if err := enetPulseSvc.FetchAndStoreTournamentTemplates(context.Background()); err != nil {
|
if err := enetPulseSvc.FetchAndStoreTournamentTemplates(ctx); err != nil {
|
||||||
mongoLogger.Error("Failed to fetch and store tournament templates",
|
mongoLogger.Error("Failed to fetch and store tournament templates", zap.Error(err))
|
||||||
zap.Error(err),
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
mongoLogger.Info("Completed fetching and storing tournament templates without errors")
|
mongoLogger.Info("✅ Completed fetching and storing tournament templates")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 3️⃣ Tournaments
|
||||||
mongoLogger.Info("Began fetching and storing tournaments cron task")
|
mongoLogger.Info("Began fetching and storing tournaments cron task")
|
||||||
if err := enetPulseSvc.FetchAndStoreTournaments(context.Background()); err != nil {
|
if err := enetPulseSvc.FetchAndStoreTournaments(ctx); err != nil {
|
||||||
mongoLogger.Error("Failed to fetch and store tournaments",
|
mongoLogger.Error("Failed to fetch and store tournaments", zap.Error(err))
|
||||||
zap.Error(err),
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
mongoLogger.Info("Completed fetching and storing tournaments without errors")
|
mongoLogger.Info("✅ Completed fetching and storing tournaments")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 4️⃣ Tournament Stages
|
||||||
mongoLogger.Info("Began fetching and storing tournament stages cron task")
|
mongoLogger.Info("Began fetching and storing tournament stages cron task")
|
||||||
if err := enetPulseSvc.FetchAndStoreTournamentStages(context.Background()); err != nil {
|
if err := enetPulseSvc.FetchAndStoreTournamentStages(ctx); err != nil {
|
||||||
mongoLogger.Error("Failed to fetch and store tournament stages",
|
mongoLogger.Error("Failed to fetch and store tournament stages", zap.Error(err))
|
||||||
zap.Error(err),
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
mongoLogger.Info("Completed fetching and storing tournament stages without errors")
|
mongoLogger.Info("✅ Completed fetching and storing tournament stages")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5️⃣ Fixtures
|
||||||
|
mongoLogger.Info("Began fetching and storing fixtures cron task")
|
||||||
|
today := time.Now().Format("2006-01-02")
|
||||||
|
if err := enetPulseSvc.FetchAndStoreFixtures(ctx, today); err != nil {
|
||||||
|
mongoLogger.Error("Failed to fetch and store fixtures", zap.Error(err))
|
||||||
|
} else {
|
||||||
|
mongoLogger.Info("✅ Completed fetching and storing fixtures")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6️⃣ Results
|
||||||
|
mongoLogger.Info("Began fetching and storing results cron task")
|
||||||
|
if err := enetPulseSvc.FetchAndStoreResults(ctx); err != nil {
|
||||||
|
mongoLogger.Error("Failed to fetch and store results", zap.Error(err))
|
||||||
|
} else {
|
||||||
|
mongoLogger.Info("✅ Completed fetching and storing results")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7 Outcome Types
|
||||||
|
mongoLogger.Info("Began fetching and storing outcome_types cron task")
|
||||||
|
if err := enetPulseSvc.FetchAndStoreOutcomeTypes(ctx); err != nil {
|
||||||
|
mongoLogger.Error("Failed to fetch and store outcome_types", zap.Error(err))
|
||||||
|
} else {
|
||||||
|
mongoLogger.Info("✅ Completed fetching and storing outcome_types")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 8 Outcome Types
|
||||||
|
mongoLogger.Info("Began fetching and storing preodds cron task")
|
||||||
|
if err := enetPulseSvc.FetchAndStorePreodds(ctx); err != nil {
|
||||||
|
mongoLogger.Error("Failed to fetch and store preodds", zap.Error(err))
|
||||||
|
} else {
|
||||||
|
mongoLogger.Info("✅ Completed fetching and storing preodds")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, job := range schedule {
|
for _, job := range schedule {
|
||||||
// Run the task immediately at startup
|
// Run immediately at startup
|
||||||
job.task()
|
job.task()
|
||||||
|
|
||||||
// Schedule the task
|
// Schedule the 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 EnetPulse cron job",
|
mongoLogger.Error("Failed to schedule EnetPulse cron job", zap.Error(err))
|
||||||
zap.Error(err),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Start()
|
c.Start()
|
||||||
log.Println("EnetPulse cron jobs started for sports, tournament templates, tournaments, and tournament stages")
|
log.Println("EnetPulse cron jobs started for sports, tournament templates, tournaments, tournament stages, fixtures, and results")
|
||||||
mongoLogger.Info("EnetPulse cron jobs started for sports, tournament templates, tournaments, and tournament stages")
|
mongoLogger.Info("EnetPulse cron jobs started for sports, tournament templates, tournaments, tournament stages, fixtures, and results")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -178,6 +178,63 @@ func (h *Handler) GetAllTournamentStages(c *fiber.Ctx) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetFixturesByDate godoc
|
||||||
|
// @Summary Get all stored fixtures
|
||||||
|
// @Description Fetches all fixtures stored in the database
|
||||||
|
// @Tags EnetPulse - Fixtures
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Success 200 {object} domain.Response{data=[]domain.EnetpulseFixture}
|
||||||
|
// @Failure 502 {object} domain.ErrorResponse
|
||||||
|
// @Router /api/v1/enetpulse/fixtures [get]
|
||||||
|
func (h *Handler) GetFixturesByDate(c *fiber.Ctx) error {
|
||||||
|
// Call service to get all fixtures from DB
|
||||||
|
fixtures, err := h.enetPulseSvc.GetAllFixtures(c.Context())
|
||||||
|
if err != nil {
|
||||||
|
log.Println("GetAllFixtures error:", err)
|
||||||
|
return c.Status(fiber.StatusBadGateway).JSON(domain.ErrorResponse{
|
||||||
|
Message: "Failed to fetch fixtures from database",
|
||||||
|
Error: err.Error(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.Status(fiber.StatusOK).JSON(domain.Response{
|
||||||
|
Message: "Fixtures fetched successfully",
|
||||||
|
Data: fixtures,
|
||||||
|
StatusCode: fiber.StatusOK,
|
||||||
|
Success: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAllResults godoc
|
||||||
|
// @Summary Get all results
|
||||||
|
// @Description Fetches all EnetPulse match results stored in the database
|
||||||
|
// @Tags EnetPulse - Results
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Success 200 {object} domain.Response{data=[]domain.EnetpulseResult}
|
||||||
|
// @Failure 502 {object} domain.ErrorResponse
|
||||||
|
// @Router /api/v1/enetpulse/results [get]
|
||||||
|
func (h *Handler) GetAllResults(c *fiber.Ctx) error {
|
||||||
|
// Call service
|
||||||
|
results, err := h.enetPulseSvc.GetAllResults(c.Context())
|
||||||
|
if err != nil {
|
||||||
|
log.Println("GetAllResults error:", err)
|
||||||
|
return c.Status(fiber.StatusBadGateway).JSON(domain.ErrorResponse{
|
||||||
|
Message: "Failed to fetch EnetPulse results",
|
||||||
|
Error: err.Error(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.Status(fiber.StatusOK).JSON(domain.Response{
|
||||||
|
Message: "EnetPulse results fetched successfully",
|
||||||
|
Data: results,
|
||||||
|
StatusCode: fiber.StatusOK,
|
||||||
|
Success: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Helper: parse comma-separated string into []int
|
// Helper: parse comma-separated string into []int
|
||||||
func parseIntSlice(input string) []int {
|
func parseIntSlice(input string) []int {
|
||||||
if input == "" {
|
if input == "" {
|
||||||
|
|
|
||||||
|
|
@ -259,7 +259,7 @@ func (a *App) initAppRoutes() {
|
||||||
tenant.Get("/odds/upcoming/:upcoming_id/market/:market_id", h.GetTenantOddsByMarketID)
|
tenant.Get("/odds/upcoming/:upcoming_id/market/:market_id", h.GetTenantOddsByMarketID)
|
||||||
tenant.Post("/odds/settings", a.CompanyOnly, h.SaveOddsSetting)
|
tenant.Post("/odds/settings", a.CompanyOnly, h.SaveOddsSetting)
|
||||||
|
|
||||||
groupV1.Get("/events", a.authMiddleware, h.GetAllEvents)
|
groupV1.Get("/events", h.GetAllEvents)
|
||||||
groupV1.Get("/events/:id", a.authMiddleware, h.GetEventByID)
|
groupV1.Get("/events/:id", a.authMiddleware, h.GetEventByID)
|
||||||
groupV1.Delete("/events/:id", a.authMiddleware, a.SuperAdminOnly, h.SetEventStatusToRemoved)
|
groupV1.Delete("/events/:id", a.authMiddleware, a.SuperAdminOnly, h.SetEventStatusToRemoved)
|
||||||
groupV1.Patch("/events/:id/is_monitored", a.authMiddleware, a.SuperAdminOnly, h.SetEventIsMonitored)
|
groupV1.Patch("/events/:id/is_monitored", a.authMiddleware, a.SuperAdminOnly, h.SetEventIsMonitored)
|
||||||
|
|
@ -275,6 +275,8 @@ func (a *App) initAppRoutes() {
|
||||||
groupV1.Get("/tournament_templates", h.GetAllTournamentTemplates)
|
groupV1.Get("/tournament_templates", h.GetAllTournamentTemplates)
|
||||||
groupV1.Get("/tournaments", h.GetAllTournamentTemplates)
|
groupV1.Get("/tournaments", h.GetAllTournamentTemplates)
|
||||||
groupV1.Get("/tournament_stages", h.GetAllTournamentStages)
|
groupV1.Get("/tournament_stages", h.GetAllTournamentStages)
|
||||||
|
groupV1.Get("/fixtures", h.GetFixturesByDate)
|
||||||
|
groupV1.Get("/results", h.GetAllResults)
|
||||||
|
|
||||||
// Leagues
|
// Leagues
|
||||||
tenant.Get("/leagues", h.GetAllLeagues)
|
tenant.Get("/leagues", h.GetAllLeagues)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user