Merge remote-tracking branch 'refs/remotes/origin/auth' into auth
This commit is contained in:
commit
35b846bcc8
|
|
@ -16,19 +16,24 @@ INSERT INTO odds (
|
||||||
source,
|
source,
|
||||||
fetched_at
|
fetched_at
|
||||||
) VALUES (
|
) VALUES (
|
||||||
$1, $2, $3, $4, $5, $6, $7,
|
$1, $2, $3, $4, $5, $6, $7,
|
||||||
$8, $9, $10, $11, $12, $13, $14, $15
|
$8, $9, $10, $11, $12, $13, $14, $15
|
||||||
)
|
)
|
||||||
ON CONFLICT (market_id, name, handicap) DO UPDATE SET
|
ON CONFLICT (event_id, market_id) DO UPDATE SET
|
||||||
odds_value = EXCLUDED.odds_value,
|
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,
|
||||||
market_category = EXCLUDED.market_category,
|
market_category = EXCLUDED.market_category,
|
||||||
fetched_at = EXCLUDED.fetched_at,
|
name = EXCLUDED.name,
|
||||||
is_active = EXCLUDED.is_active,
|
handicap = EXCLUDED.handicap,
|
||||||
source = EXCLUDED.source,
|
fetched_at = EXCLUDED.fetched_at,
|
||||||
fi = EXCLUDED.fi;
|
is_active = EXCLUDED.is_active,
|
||||||
|
source = EXCLUDED.source,
|
||||||
|
fi = EXCLUDED.fi;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- name: GetPrematchOdds :many
|
-- name: GetPrematchOdds :many
|
||||||
SELECT
|
SELECT
|
||||||
|
|
@ -70,17 +75,17 @@ SELECT
|
||||||
FROM odds
|
FROM odds
|
||||||
WHERE is_active = true AND source = 'b365api';
|
WHERE is_active = true AND source = 'b365api';
|
||||||
|
|
||||||
-- name: GetRawOddsByID :one
|
-- name: GetRawOddsByMarketID :many
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
id,
|
||||||
raw_odds,
|
raw_odds,
|
||||||
fetched_at
|
fetched_at
|
||||||
FROM odds
|
FROM odds
|
||||||
WHERE
|
WHERE
|
||||||
raw_odds @> $1::jsonb AND
|
market_id = $1 AND
|
||||||
is_active = true AND
|
is_active = true AND
|
||||||
source = 'b365api'
|
source = 'b365api'
|
||||||
LIMIT 1;
|
LIMIT $2 OFFSET $3;
|
||||||
|
|
||||||
-- name: GetPrematchOddsByUpcomingID :many
|
-- name: GetPrematchOddsByUpcomingID :many
|
||||||
SELECT
|
SELECT
|
||||||
|
|
|
||||||
20
docs/docs.go
20
docs/docs.go
|
|
@ -1354,9 +1354,9 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/prematch/odds/raw/{raw_odds_id}": {
|
"/prematch/odds/raw/{market_id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"description": "Retrieve raw odds by raw odds ID",
|
"description": "Retrieve raw odds records using a Market ID",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
|
|
@ -1366,12 +1366,12 @@ const docTemplate = `{
|
||||||
"tags": [
|
"tags": [
|
||||||
"prematch"
|
"prematch"
|
||||||
],
|
],
|
||||||
"summary": "Retrieve raw odds by ID",
|
"summary": "Retrieve raw odds by Market ID",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Raw Odds ID",
|
"description": "Market ID",
|
||||||
"name": "raw_odds_id",
|
"name": "market_id",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"required": true
|
"required": true
|
||||||
}
|
}
|
||||||
|
|
@ -1380,7 +1380,10 @@ const docTemplate = `{
|
||||||
"200": {
|
"200": {
|
||||||
"description": "OK",
|
"description": "OK",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/domain.RawOddsByID"
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/domain.RawOddsByMarketID"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
|
|
@ -2672,12 +2675,9 @@ const docTemplate = `{
|
||||||
"BANK"
|
"BANK"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"domain.RawOddsByID": {
|
"domain.RawOddsByMarketID": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"event_id": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"fetched_at": {
|
"fetched_at": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1346,9 +1346,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/prematch/odds/raw/{raw_odds_id}": {
|
"/prematch/odds/raw/{market_id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"description": "Retrieve raw odds by raw odds ID",
|
"description": "Retrieve raw odds records using a Market ID",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
|
|
@ -1358,12 +1358,12 @@
|
||||||
"tags": [
|
"tags": [
|
||||||
"prematch"
|
"prematch"
|
||||||
],
|
],
|
||||||
"summary": "Retrieve raw odds by ID",
|
"summary": "Retrieve raw odds by Market ID",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Raw Odds ID",
|
"description": "Market ID",
|
||||||
"name": "raw_odds_id",
|
"name": "market_id",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"required": true
|
"required": true
|
||||||
}
|
}
|
||||||
|
|
@ -1372,7 +1372,10 @@
|
||||||
"200": {
|
"200": {
|
||||||
"description": "OK",
|
"description": "OK",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/domain.RawOddsByID"
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/domain.RawOddsByMarketID"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
|
|
@ -2664,12 +2667,9 @@
|
||||||
"BANK"
|
"BANK"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"domain.RawOddsByID": {
|
"domain.RawOddsByMarketID": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"event_id": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"fetched_at": {
|
"fetched_at": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -68,10 +68,8 @@ definitions:
|
||||||
- TELEBIRR_TRANSACTION
|
- TELEBIRR_TRANSACTION
|
||||||
- ARIFPAY_TRANSACTION
|
- ARIFPAY_TRANSACTION
|
||||||
- BANK
|
- BANK
|
||||||
domain.RawOddsByID:
|
domain.RawOddsByMarketID:
|
||||||
properties:
|
properties:
|
||||||
event_id:
|
|
||||||
type: string
|
|
||||||
fetched_at:
|
fetched_at:
|
||||||
type: string
|
type: string
|
||||||
id:
|
id:
|
||||||
|
|
@ -1706,15 +1704,15 @@ paths:
|
||||||
summary: Retrieve prematch odds for an event
|
summary: Retrieve prematch odds for an event
|
||||||
tags:
|
tags:
|
||||||
- prematch
|
- prematch
|
||||||
/prematch/odds/raw/{raw_odds_id}:
|
/prematch/odds/raw/{market_id}:
|
||||||
get:
|
get:
|
||||||
consumes:
|
consumes:
|
||||||
- application/json
|
- application/json
|
||||||
description: Retrieve raw odds by raw odds ID
|
description: Retrieve raw odds records using a Market ID
|
||||||
parameters:
|
parameters:
|
||||||
- description: Raw Odds ID
|
- description: Market ID
|
||||||
in: path
|
in: path
|
||||||
name: raw_odds_id
|
name: market_id
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
produces:
|
produces:
|
||||||
|
|
@ -1723,7 +1721,9 @@ paths:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/domain.RawOddsByID'
|
items:
|
||||||
|
$ref: '#/definitions/domain.RawOddsByMarketID'
|
||||||
|
type: array
|
||||||
"400":
|
"400":
|
||||||
description: Bad Request
|
description: Bad Request
|
||||||
schema:
|
schema:
|
||||||
|
|
@ -1732,7 +1732,7 @@ paths:
|
||||||
description: Internal Server Error
|
description: Internal Server Error
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/response.APIResponse'
|
$ref: '#/definitions/response.APIResponse'
|
||||||
summary: Retrieve raw odds by ID
|
summary: Retrieve raw odds by Market ID
|
||||||
tags:
|
tags:
|
||||||
- prematch
|
- prematch
|
||||||
/prematch/odds/upcoming/{upcoming_id}:
|
/prematch/odds/upcoming/{upcoming_id}:
|
||||||
|
|
|
||||||
|
|
@ -247,28 +247,47 @@ func (q *Queries) GetPrematchOddsByUpcomingID(ctx context.Context, arg GetPremat
|
||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
const GetRawOddsByID = `-- name: GetRawOddsByID :one
|
const GetRawOddsByMarketID = `-- name: GetRawOddsByMarketID :many
|
||||||
SELECT id,
|
SELECT id,
|
||||||
raw_odds,
|
raw_odds,
|
||||||
fetched_at
|
fetched_at
|
||||||
FROM odds
|
FROM odds
|
||||||
WHERE raw_odds @> $1::jsonb
|
WHERE market_id = $1
|
||||||
AND is_active = true
|
AND is_active = true
|
||||||
AND source = 'b365api'
|
AND source = 'b365api'
|
||||||
LIMIT 1
|
LIMIT $2 OFFSET $3
|
||||||
`
|
`
|
||||||
|
|
||||||
type GetRawOddsByIDRow struct {
|
type GetRawOddsByMarketIDParams struct {
|
||||||
|
MarketID pgtype.Text
|
||||||
|
Limit int32
|
||||||
|
Offset int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetRawOddsByMarketIDRow struct {
|
||||||
ID int32 `json:"id"`
|
ID int32 `json:"id"`
|
||||||
RawOdds []byte `json:"raw_odds"`
|
RawOdds []byte `json:"raw_odds"`
|
||||||
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) GetRawOddsByID(ctx context.Context, dollar_1 []byte) (GetRawOddsByIDRow, error) {
|
func (q *Queries) GetRawOddsByMarketID(ctx context.Context, arg GetRawOddsByMarketIDParams) ([]GetRawOddsByMarketIDRow, error) {
|
||||||
row := q.db.QueryRow(ctx, GetRawOddsByID, dollar_1)
|
rows, err := q.db.Query(ctx, GetRawOddsByMarketID, arg.MarketID, arg.Limit, arg.Offset)
|
||||||
var i GetRawOddsByIDRow
|
if err != nil {
|
||||||
err := row.Scan(&i.ID, &i.RawOdds, &i.FetchedAt)
|
return nil, err
|
||||||
return i, err
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
var items []GetRawOddsByMarketIDRow
|
||||||
|
for rows.Next() {
|
||||||
|
var i GetRawOddsByMarketIDRow
|
||||||
|
if err := rows.Scan(&i.ID, &i.RawOdds, &i.FetchedAt); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
items = append(items, i)
|
||||||
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return items, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
const InsertNonLiveOdd = `-- name: InsertNonLiveOdd :exec
|
const InsertNonLiveOdd = `-- name: InsertNonLiveOdd :exec
|
||||||
|
|
@ -311,6 +330,30 @@ 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,
|
||||||
|
event_id,
|
||||||
|
fi,
|
||||||
|
market_type,
|
||||||
|
market_name,
|
||||||
|
market_category,
|
||||||
|
market_id,
|
||||||
|
name,
|
||||||
|
handicap,
|
||||||
|
odds_value,
|
||||||
|
section,
|
||||||
|
category,
|
||||||
|
raw_odds,
|
||||||
|
is_active,
|
||||||
|
source,
|
||||||
|
fetched_at
|
||||||
|
) VALUES (
|
||||||
|
$1, $2, $3, $4, $5, $6, $7,
|
||||||
|
$8, $9, $10, $11, $12, $13, $14, $15
|
||||||
|
)
|
||||||
|
ON CONFLICT (event_id, market_id) DO UPDATE SET
|
||||||
|
odds_value = EXCLUDED.odds_value,
|
||||||
|
raw_odds = EXCLUDED.raw_odds,
|
||||||
|
market_type = EXCLUDED.market_type,
|
||||||
|
market_name = EXCLUDED.market_name,
|
||||||
market_category = EXCLUDED.market_category,
|
market_category = EXCLUDED.market_category,
|
||||||
fetched_at = EXCLUDED.fetched_at,
|
fetched_at = EXCLUDED.fetched_at,
|
||||||
is_active = EXCLUDED.is_active,
|
is_active = EXCLUDED.is_active,
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,8 @@ type Odd struct {
|
||||||
Source string `json:"source"`
|
Source string `json:"source"`
|
||||||
IsActive bool `json:"is_active"`
|
IsActive bool `json:"is_active"`
|
||||||
}
|
}
|
||||||
type RawOddsByID struct {
|
type RawOddsByMarketID struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
EventID string `json:"event_id"`
|
RawOdds []RawMessage `json:"raw_odds"`
|
||||||
RawOdds []RawMessage `json:"raw_odds"`
|
FetchedAt time.Time `json:"fetched_at"`
|
||||||
FetchedAt time.Time `json:"fetched_at"`
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
package repository
|
package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
"fmt"
|
||||||
"strconv"
|
"os"
|
||||||
"time"
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
dbgen "github.com/SamuelTariku/FortuneBet-Backend/gen/db"
|
dbgen "github.com/SamuelTariku/FortuneBet-Backend/gen/db"
|
||||||
"github.com/SamuelTariku/FortuneBet-Backend/internal/domain"
|
"github.com/SamuelTariku/FortuneBet-Backend/internal/domain"
|
||||||
"github.com/jackc/pgx/v5/pgtype"
|
"github.com/jackc/pgx/v5/pgtype"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Store) SaveNonLiveMarket(ctx context.Context, m domain.Market) error {
|
func (s *Store) SaveNonLiveMarket(ctx context.Context, m domain.Market) error {
|
||||||
|
|
@ -175,21 +176,31 @@ func (s *Store) GetALLPrematchOdds(ctx context.Context) ([]domain.Odd, error) {
|
||||||
return domainOdds, nil
|
return domainOdds, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Store) GetRawOddsByID(ctx context.Context, rawOddsID string) (domain.RawOddsByID, error) {
|
func (s *Store) GetRawOddsByMarketID(ctx context.Context, rawOddsID string) (domain.RawOddsByMarketID, error) {
|
||||||
jsonFilter := `[{"id":"` + rawOddsID + `"}]`
|
params := dbgen.GetRawOddsByMarketIDParams{
|
||||||
|
MarketID: pgtype.Text{String: rawOddsID, Valid: true},
|
||||||
odd, err := s.queries.GetRawOddsByID(ctx, []byte(jsonFilter))
|
Limit: 1,
|
||||||
if err != nil {
|
Offset: 0,
|
||||||
return domain.RawOddsByID{}, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rows, err := s.queries.GetRawOddsByMarketID(ctx, params)
|
||||||
|
if err != nil {
|
||||||
|
return domain.RawOddsByMarketID{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(rows) == 0 {
|
||||||
|
return domain.RawOddsByMarketID{}, fmt.Errorf("no raw odds found for market_id: %s", rawOddsID)
|
||||||
|
}
|
||||||
|
|
||||||
|
row := rows[0]
|
||||||
|
|
||||||
var rawOdds []json.RawMessage
|
var rawOdds []json.RawMessage
|
||||||
if err := json.Unmarshal(odd.RawOdds, &rawOdds); err != nil {
|
if err := json.Unmarshal(row.RawOdds, &rawOdds); err != nil {
|
||||||
return domain.RawOddsByID{}, err
|
return domain.RawOddsByMarketID{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return domain.RawOddsByID{
|
return domain.RawOddsByMarketID{
|
||||||
ID: int64(odd.ID),
|
ID: int64(row.ID),
|
||||||
RawOdds: func() []domain.RawMessage {
|
RawOdds: func() []domain.RawMessage {
|
||||||
converted := make([]domain.RawMessage, len(rawOdds))
|
converted := make([]domain.RawMessage, len(rawOdds))
|
||||||
for i, r := range rawOdds {
|
for i, r := range rawOdds {
|
||||||
|
|
@ -197,19 +208,17 @@ func (s *Store) GetRawOddsByID(ctx context.Context, rawOddsID string) (domain.Ra
|
||||||
}
|
}
|
||||||
return converted
|
return converted
|
||||||
}(),
|
}(),
|
||||||
FetchedAt: odd.FetchedAt.Time,
|
FetchedAt: row.FetchedAt.Time,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Store) GetPrematchOddsByUpcomingID(ctx context.Context, upcomingID string, limit, offset int32) ([]domain.Odd, error) {
|
func (s *Store) GetPrematchOddsByUpcomingID(ctx context.Context, upcomingID string, limit, offset int32) ([]domain.Odd, error) {
|
||||||
// Prepare query parameters
|
|
||||||
params := dbgen.GetPrematchOddsByUpcomingIDParams{
|
params := dbgen.GetPrematchOddsByUpcomingIDParams{
|
||||||
ID: upcomingID,
|
ID: upcomingID,
|
||||||
Limit: limit,
|
Limit: limit,
|
||||||
Offset: offset,
|
Offset: offset,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute the query
|
|
||||||
odds, err := s.queries.GetPrematchOddsByUpcomingID(ctx, params)
|
odds, err := s.queries.GetPrematchOddsByUpcomingID(ctx, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ type Service interface {
|
||||||
FetchNonLiveOdds(ctx context.Context) error
|
FetchNonLiveOdds(ctx context.Context) error
|
||||||
GetPrematchOdds(ctx context.Context, eventID string) ([]domain.Odd, error)
|
GetPrematchOdds(ctx context.Context, eventID string) ([]domain.Odd, error)
|
||||||
GetALLPrematchOdds(ctx context.Context) ([]domain.Odd, error)
|
GetALLPrematchOdds(ctx context.Context) ([]domain.Odd, error)
|
||||||
GetRawOddsByID(ctx context.Context, rawOddsID string) ([]domain.RawOddsByID, error)
|
GetRawOddsByMarketID(ctx context.Context, marketID string) ([]domain.RawOddsByMarketID, error)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,13 +122,15 @@ func (s *ServiceImpl) GetALLPrematchOdds(ctx context.Context) ([]domain.Odd, err
|
||||||
return s.store.GetALLPrematchOdds(ctx)
|
return s.store.GetALLPrematchOdds(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ServiceImpl) GetRawOddsByID(ctx context.Context, rawOddsID string) ([]domain.RawOddsByID, error) {
|
func (s *ServiceImpl) GetRawOddsByMarketID(ctx context.Context, marketID string) ([]domain.RawOddsByMarketID, error) {
|
||||||
rawOdds, err := s.store.GetRawOddsByID(ctx, rawOddsID)
|
rows, err := s.store.GetRawOddsByMarketID(ctx, marketID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return []domain.RawOddsByID{rawOdds}, nil
|
|
||||||
|
return []domain.RawOddsByMarketID{rows}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ServiceImpl) GetPrematchOddsByUpcomingID(ctx context.Context, upcomingID string, limit, offset int32) ([]domain.Odd, error) {
|
func (s *ServiceImpl) GetPrematchOddsByUpcomingID(ctx context.Context, upcomingID string, limit, offset int32) ([]domain.Odd, error) {
|
||||||
return s.store.GetPrematchOddsByUpcomingID(ctx, upcomingID, limit, offset)
|
return s.store.GetPrematchOddsByUpcomingID(ctx, upcomingID, limit, offset)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ func StartDataFetchingCrons(eventService eventsvc.Service, oddsService oddssvc.S
|
||||||
// },
|
// },
|
||||||
|
|
||||||
|
|
||||||
// {
|
// {
|
||||||
// spec: "*/30 * * * * *", // Every 30 seconds
|
// spec: "*/5 * * * * *", // Every 5 seconds
|
||||||
// task: func() {
|
// task: func() {
|
||||||
// if err := oddsService.FetchNonLiveOdds(context.Background()); err != nil {
|
// if err := oddsService.FetchNonLiveOdds(context.Background()); err != nil {
|
||||||
// log.Printf("FetchNonLiveOdds error: %v", err)
|
// log.Printf("FetchNonLiveOdds error: %v", err)
|
||||||
|
|
|
||||||
|
|
@ -55,26 +55,27 @@ func GetALLPrematchOdds(logger *slog.Logger, prematchSvc *odds.ServiceImpl) fibe
|
||||||
return response.WriteJSON(c, fiber.StatusOK, "All prematch odds retrieved successfully", odds, nil)
|
return response.WriteJSON(c, fiber.StatusOK, "All prematch odds retrieved successfully", odds, nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// GetRawOddsByID
|
// GetRawOddsByMarketID
|
||||||
// @Summary Retrieve raw odds by ID
|
// @Summary Retrieve raw odds by Market ID
|
||||||
// @Description Retrieve raw odds by raw odds ID
|
// @Description Retrieve raw odds records using a Market ID
|
||||||
// @Tags prematch
|
// @Tags prematch
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param raw_odds_id path string true "Raw Odds ID"
|
// @Param market_id path string true "Market ID"
|
||||||
// @Success 200 {object} domain.RawOddsByID
|
// @Success 200 {array} domain.RawOddsByMarketID
|
||||||
// @Failure 400 {object} response.APIResponse
|
// @Failure 400 {object} response.APIResponse
|
||||||
// @Failure 500 {object} response.APIResponse
|
// @Failure 500 {object} response.APIResponse
|
||||||
// @Router /prematch/odds/raw/{raw_odds_id} [get]
|
// @Router /prematch/odds/raw/{market_id} [get]
|
||||||
func GetRawOddsByID(logger *slog.Logger, prematchSvc *odds.ServiceImpl) fiber.Handler {
|
func GetRawOddsByMarketID(logger *slog.Logger, prematchSvc *odds.ServiceImpl) fiber.Handler {
|
||||||
return func(c *fiber.Ctx) error {
|
return func(c *fiber.Ctx) error {
|
||||||
rawOddsID := c.Params("raw_odds_id")
|
marketID := c.Params("market_id")
|
||||||
if rawOddsID == "" {
|
if marketID == "" {
|
||||||
return response.WriteJSON(c, fiber.StatusBadRequest, "Missing raw_odds_id", nil, nil)
|
return response.WriteJSON(c, fiber.StatusBadRequest, "Missing market_id", nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
rawOdds, err := prematchSvc.GetRawOddsByID(c.Context(), rawOddsID)
|
rawOdds, err := prematchSvc.GetRawOddsByMarketID(c.Context(), marketID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logger.Error("failed to fetch raw odds", "error", err)
|
||||||
return response.WriteJSON(c, fiber.StatusInternalServerError, "Failed to retrieve raw odds", nil, nil)
|
return response.WriteJSON(c, fiber.StatusInternalServerError, "Failed to retrieve raw odds", nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ func (a *App) initAppRoutes() {
|
||||||
|
|
||||||
a.fiber.Get("/prematch/odds/:event_id", handlers.GetPrematchOdds(a.logger, a.prematchSvc))
|
a.fiber.Get("/prematch/odds/:event_id", handlers.GetPrematchOdds(a.logger, a.prematchSvc))
|
||||||
a.fiber.Get("/prematch/odds", handlers.GetALLPrematchOdds(a.logger, a.prematchSvc))
|
a.fiber.Get("/prematch/odds", handlers.GetALLPrematchOdds(a.logger, a.prematchSvc))
|
||||||
a.fiber.Get("/prematch/odds/raw/:raw_odds_id", handlers.GetRawOddsByID(a.logger, a.prematchSvc))
|
a.fiber.Get("/prematch/odds/raw/:market_id", handlers.GetRawOddsByMarketID(a.logger, a.prematchSvc))
|
||||||
|
|
||||||
a.fiber.Get("/prematch/events/:id", handlers.GetUpcomingEventByID(a.logger, a.eventSvc))
|
a.fiber.Get("/prematch/events/:id", handlers.GetUpcomingEventByID(a.logger, a.eventSvc))
|
||||||
a.fiber.Get("/prematch/events", handlers.GetAllUpcomingEvents(a.logger, a.eventSvc))
|
a.fiber.Get("/prematch/events", handlers.GetAllUpcomingEvents(a.logger, a.eventSvc))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user