small fix
This commit is contained in:
parent
98cb576873
commit
788119f718
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -4,3 +4,4 @@ coverage
|
||||||
.env
|
.env
|
||||||
tmp
|
tmp
|
||||||
build
|
build
|
||||||
|
*.log
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,6 @@ CREATE TABLE IF NOT EXISTS branch_cashiers (
|
||||||
branch_id BIGINT NOT NULL,
|
branch_id BIGINT NOT NULL,
|
||||||
UNIQUE(user_id, branch_id)
|
UNIQUE(user_id, branch_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE events (
|
CREATE TABLE events (
|
||||||
id TEXT PRIMARY KEY,
|
id TEXT PRIMARY KEY,
|
||||||
sport_id TEXT,
|
sport_id TEXT,
|
||||||
|
|
@ -217,24 +216,14 @@ CREATE TABLE odds (
|
||||||
fetched_at TIMESTAMP DEFAULT now(),
|
fetched_at TIMESTAMP DEFAULT now(),
|
||||||
source TEXT DEFAULT 'b365api',
|
source TEXT DEFAULT 'b365api',
|
||||||
is_active BOOLEAN DEFAULT true,
|
is_active BOOLEAN DEFAULT true,
|
||||||
|
UNIQUE (market_id, name, handicap),
|
||||||
UNIQUE (event_id, market_id, name, handicap)
|
UNIQUE (event_id, market_id, name, handicap)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ALTER TABLE refresh_tokens
|
ALTER TABLE refresh_tokens
|
||||||
ADD CONSTRAINT fk_refresh_tokens_users FOREIGN KEY (user_id) REFERENCES users(id);
|
ADD CONSTRAINT fk_refresh_tokens_users FOREIGN KEY (user_id) REFERENCES users(id);
|
||||||
ALTER TABLE bets
|
ALTER TABLE bets
|
||||||
ADD CONSTRAINT fk_bets_users FOREIGN KEY (user_id) REFERENCES users(id),
|
ADD CONSTRAINT fk_bets_users FOREIGN KEY (user_id) REFERENCES users(id),
|
||||||
ADD CONSTRAINT fk_bets_branches FOREIGN KEY (branch_id) REFERENCES branches(id);
|
ADD CONSTRAINT fk_bets_branches FOREIGN KEY (branch_id) REFERENCES branches(id);
|
||||||
ALTER TABLE bet_outcomes
|
|
||||||
ADD CONSTRAINT fk_bet_outcomes_bets FOREIGN KEY (bet_id) REFERENCES bets(id),
|
|
||||||
ADD CONSTRAINT fk_bet_outcomes_events FOREIGN KEY (event_id) REFERENCES supported_operations(id),
|
|
||||||
ADD CONSTRAINT fk_bet_outcomes_odds FOREIGN KEY (odd_id) REFERENCES supported_operations(id);
|
|
||||||
ALTER TABLE ticket_outcomes
|
|
||||||
ADD CONSTRAINT fk_ticket_outcomes_tickets FOREIGN KEY (ticket_id) REFERENCES tickets(id),
|
|
||||||
ADD CONSTRAINT fk_ticket_outcomes_events FOREIGN KEY (event_id) REFERENCES supported_operations(id),
|
|
||||||
ADD CONSTRAINT fk_ticket_outcomes_odds FOREIGN KEY (odd_id) REFERENCES supported_operations(id);
|
|
||||||
ALTER TABLE wallets
|
ALTER TABLE wallets
|
||||||
ADD CONSTRAINT fk_wallets_users FOREIGN KEY (user_id) REFERENCES users(id);
|
ADD CONSTRAINT fk_wallets_users FOREIGN KEY (user_id) REFERENCES users(id);
|
||||||
ALTER TABLE customer_wallets
|
ALTER TABLE customer_wallets
|
||||||
|
|
@ -341,5 +330,4 @@ VALUES (
|
||||||
CURRENT_TIMESTAMP,
|
CURRENT_TIMESTAMP,
|
||||||
CURRENT_TIMESTAMP
|
CURRENT_TIMESTAMP
|
||||||
);
|
);
|
||||||
|
|
||||||
--------------------------------------------------Bet365 Data Fetching + Event Managment------------------------------------------------
|
--------------------------------------------------Bet365 Data Fetching + Event Managment------------------------------------------------
|
||||||
|
|
@ -148,6 +148,7 @@ type Odd struct {
|
||||||
MarketCategory pgtype.Text `json:"market_category"`
|
MarketCategory pgtype.Text `json:"market_category"`
|
||||||
MarketID pgtype.Text `json:"market_id"`
|
MarketID pgtype.Text `json:"market_id"`
|
||||||
Name pgtype.Text `json:"name"`
|
Name pgtype.Text `json:"name"`
|
||||||
|
Header pgtype.Text `json:"header"`
|
||||||
Handicap pgtype.Text `json:"handicap"`
|
Handicap pgtype.Text `json:"handicap"`
|
||||||
OddsValue pgtype.Float8 `json:"odds_value"`
|
OddsValue pgtype.Float8 `json:"odds_value"`
|
||||||
Section string `json:"section"`
|
Section string `json:"section"`
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const GetALLPrematchOdds = `-- name: GetALLPrematchOdds :many
|
const GetALLPrematchOdds = `-- name: GetALLPrematchOdds :many
|
||||||
SELECT
|
SELECT event_id,
|
||||||
event_id,
|
|
||||||
fi,
|
fi,
|
||||||
market_type,
|
market_type,
|
||||||
market_name,
|
market_name,
|
||||||
|
|
@ -29,7 +28,8 @@ SELECT
|
||||||
source,
|
source,
|
||||||
is_active
|
is_active
|
||||||
FROM odds
|
FROM odds
|
||||||
WHERE is_active = true AND source = 'b365api'
|
WHERE is_active = true
|
||||||
|
AND source = 'b365api'
|
||||||
`
|
`
|
||||||
|
|
||||||
type GetALLPrematchOddsRow struct {
|
type GetALLPrematchOddsRow struct {
|
||||||
|
|
@ -87,8 +87,7 @@ func (q *Queries) GetALLPrematchOdds(ctx context.Context) ([]GetALLPrematchOddsR
|
||||||
}
|
}
|
||||||
|
|
||||||
const GetPrematchOdds = `-- name: GetPrematchOdds :many
|
const GetPrematchOdds = `-- name: GetPrematchOdds :many
|
||||||
SELECT
|
SELECT event_id,
|
||||||
event_id,
|
|
||||||
fi,
|
fi,
|
||||||
market_type,
|
market_type,
|
||||||
market_name,
|
market_name,
|
||||||
|
|
@ -104,7 +103,8 @@ SELECT
|
||||||
source,
|
source,
|
||||||
is_active
|
is_active
|
||||||
FROM odds
|
FROM odds
|
||||||
WHERE is_active = true AND source = 'b365api'
|
WHERE is_active = true
|
||||||
|
AND source = 'b365api'
|
||||||
`
|
`
|
||||||
|
|
||||||
type GetPrematchOddsRow struct {
|
type GetPrematchOddsRow struct {
|
||||||
|
|
@ -162,8 +162,7 @@ func (q *Queries) GetPrematchOdds(ctx context.Context) ([]GetPrematchOddsRow, er
|
||||||
}
|
}
|
||||||
|
|
||||||
const GetPrematchOddsByUpcomingID = `-- name: GetPrematchOddsByUpcomingID :many
|
const GetPrematchOddsByUpcomingID = `-- name: GetPrematchOddsByUpcomingID :many
|
||||||
SELECT
|
SELECT o.event_id,
|
||||||
o.event_id,
|
|
||||||
o.fi,
|
o.fi,
|
||||||
o.market_type,
|
o.market_type,
|
||||||
o.market_name,
|
o.market_name,
|
||||||
|
|
@ -179,7 +178,7 @@ SELECT
|
||||||
o.source,
|
o.source,
|
||||||
o.is_active
|
o.is_active
|
||||||
FROM odds o
|
FROM odds o
|
||||||
JOIN events e ON o.fi = e.id
|
JOIN events e ON o.fi = e.id
|
||||||
WHERE e.id = $1
|
WHERE e.id = $1
|
||||||
AND e.is_live = false
|
AND e.is_live = false
|
||||||
AND e.status = 'upcoming'
|
AND e.status = 'upcoming'
|
||||||
|
|
@ -249,15 +248,13 @@ func (q *Queries) GetPrematchOddsByUpcomingID(ctx context.Context, arg GetPremat
|
||||||
}
|
}
|
||||||
|
|
||||||
const GetRawOddsByID = `-- name: GetRawOddsByID :one
|
const GetRawOddsByID = `-- name: GetRawOddsByID :one
|
||||||
SELECT
|
SELECT id,
|
||||||
id,
|
|
||||||
raw_odds,
|
raw_odds,
|
||||||
fetched_at
|
fetched_at
|
||||||
FROM odds
|
FROM odds
|
||||||
WHERE
|
WHERE raw_odds @> $1::jsonb
|
||||||
raw_odds @> $1::jsonb AND
|
AND is_active = true
|
||||||
is_active = true AND
|
AND source = 'b365api'
|
||||||
source = 'b365api'
|
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|
@ -291,12 +288,26 @@ INSERT INTO odds (
|
||||||
is_active,
|
is_active,
|
||||||
source,
|
source,
|
||||||
fetched_at
|
fetched_at
|
||||||
) VALUES (
|
)
|
||||||
$1, $2, $3, $4, $5, $6, $7,
|
VALUES (
|
||||||
$8, $9, $10, $11, $12, $13, $14, $15
|
$1,
|
||||||
)
|
$2,
|
||||||
ON CONFLICT (market_id, name, handicap) DO UPDATE SET
|
$3,
|
||||||
odds_value = EXCLUDED.odds_value,
|
$4,
|
||||||
|
$5,
|
||||||
|
$6,
|
||||||
|
$7,
|
||||||
|
$8,
|
||||||
|
$9,
|
||||||
|
$10,
|
||||||
|
$11,
|
||||||
|
$12,
|
||||||
|
$13,
|
||||||
|
$14,
|
||||||
|
$15
|
||||||
|
) ON CONFLICT (market_id, name, handicap) DO
|
||||||
|
UPDATE
|
||||||
|
SET odds_value = EXCLUDED.odds_value,
|
||||||
raw_odds = EXCLUDED.raw_odds,
|
raw_odds = EXCLUDED.raw_odds,
|
||||||
market_type = EXCLUDED.market_type,
|
market_type = EXCLUDED.market_type,
|
||||||
market_name = EXCLUDED.market_name,
|
market_name = EXCLUDED.market_name,
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
|
||||||
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/authentication"
|
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/authentication"
|
||||||
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/event"
|
|
||||||
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/odds"
|
|
||||||
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/bet"
|
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/bet"
|
||||||
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/branch"
|
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/branch"
|
||||||
|
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/event"
|
||||||
|
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/odds"
|
||||||
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/ticket"
|
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/ticket"
|
||||||
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/transaction"
|
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/transaction"
|
||||||
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/user"
|
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/user"
|
||||||
|
|
@ -16,7 +16,6 @@ import (
|
||||||
jwtutil "github.com/SamuelTariku/FortuneBet-Backend/internal/web_server/jwt"
|
jwtutil "github.com/SamuelTariku/FortuneBet-Backend/internal/web_server/jwt"
|
||||||
customvalidator "github.com/SamuelTariku/FortuneBet-Backend/internal/web_server/validator"
|
customvalidator "github.com/SamuelTariku/FortuneBet-Backend/internal/web_server/validator"
|
||||||
|
|
||||||
|
|
||||||
notificationservice "github.com/SamuelTariku/FortuneBet-Backend/internal/services/notfication"
|
notificationservice "github.com/SamuelTariku/FortuneBet-Backend/internal/services/notfication"
|
||||||
"github.com/bytedance/sonic"
|
"github.com/bytedance/sonic"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
@ -65,9 +64,10 @@ func NewApp(
|
||||||
})
|
})
|
||||||
|
|
||||||
app.Use(cors.New(cors.Config{
|
app.Use(cors.New(cors.Config{
|
||||||
AllowOrigins: "http://localhost:5173", // Specify your frontend's origin
|
AllowOrigins: "http://localhost:8000", // Specify your frontend's origin
|
||||||
AllowMethods: "GET,POST,PUT,DELETE", // Specify the allowed HTTP methods
|
AllowMethods: "GET,POST,PUT,DELETE,OPTIONS", // Specify the allowed HTTP methods
|
||||||
AllowHeaders: "Content-Type,Authorization", // Specify the allowed headers
|
AllowHeaders: "Content-Type,Authorization,platform", // Specify the allowed headers
|
||||||
|
AllowCredentials: true,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
s := &App{
|
s := &App{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user