261 lines
5.3 KiB
Go
261 lines
5.3 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.28.0
|
|
// source: odds.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const GetALLPrematchOdds = `-- name: GetALLPrematchOdds :many
|
|
SELECT
|
|
id,
|
|
event_id,
|
|
fi,
|
|
market_type,
|
|
market_name,
|
|
market_category,
|
|
market_id,
|
|
name,
|
|
handicap,
|
|
odds_value,
|
|
section,
|
|
category,
|
|
raw_odds,
|
|
fetched_at,
|
|
source,
|
|
is_active
|
|
FROM odds
|
|
WHERE is_active = true AND source = 'b365api'
|
|
`
|
|
|
|
type GetALLPrematchOddsRow struct {
|
|
ID int32
|
|
EventID pgtype.Text
|
|
Fi pgtype.Text
|
|
MarketType string
|
|
MarketName pgtype.Text
|
|
MarketCategory pgtype.Text
|
|
MarketID pgtype.Text
|
|
Name pgtype.Text
|
|
Handicap pgtype.Text
|
|
OddsValue pgtype.Float8
|
|
Section string
|
|
Category pgtype.Text
|
|
RawOdds []byte
|
|
FetchedAt pgtype.Timestamp
|
|
Source pgtype.Text
|
|
IsActive pgtype.Bool
|
|
}
|
|
|
|
func (q *Queries) GetALLPrematchOdds(ctx context.Context) ([]GetALLPrematchOddsRow, error) {
|
|
rows, err := q.db.Query(ctx, GetALLPrematchOdds)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []GetALLPrematchOddsRow
|
|
for rows.Next() {
|
|
var i GetALLPrematchOddsRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.EventID,
|
|
&i.Fi,
|
|
&i.MarketType,
|
|
&i.MarketName,
|
|
&i.MarketCategory,
|
|
&i.MarketID,
|
|
&i.Name,
|
|
&i.Handicap,
|
|
&i.OddsValue,
|
|
&i.Section,
|
|
&i.Category,
|
|
&i.RawOdds,
|
|
&i.FetchedAt,
|
|
&i.Source,
|
|
&i.IsActive,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const GetPrematchOdds = `-- name: GetPrematchOdds :many
|
|
SELECT
|
|
id,
|
|
event_id,
|
|
fi,
|
|
raw_event_id,
|
|
market_type,
|
|
market_name,
|
|
market_category,
|
|
market_id,
|
|
header,
|
|
name,
|
|
handicap,
|
|
odds_value,
|
|
section,
|
|
category,
|
|
raw_odds,
|
|
fetched_at,
|
|
source,
|
|
is_active
|
|
FROM odds
|
|
WHERE event_id = $1 AND is_active = true AND source = 'b365api'
|
|
`
|
|
|
|
func (q *Queries) GetPrematchOdds(ctx context.Context, eventID pgtype.Text) ([]Odd, error) {
|
|
rows, err := q.db.Query(ctx, GetPrematchOdds, eventID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Odd
|
|
for rows.Next() {
|
|
var i Odd
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.EventID,
|
|
&i.Fi,
|
|
&i.RawEventID,
|
|
&i.MarketType,
|
|
&i.MarketName,
|
|
&i.MarketCategory,
|
|
&i.MarketID,
|
|
&i.Header,
|
|
&i.Name,
|
|
&i.Handicap,
|
|
&i.OddsValue,
|
|
&i.Section,
|
|
&i.Category,
|
|
&i.RawOdds,
|
|
&i.FetchedAt,
|
|
&i.Source,
|
|
&i.IsActive,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const GetRawOddsByID = `-- name: GetRawOddsByID :one
|
|
SELECT
|
|
id,
|
|
event_id,
|
|
raw_odds,
|
|
fetched_at
|
|
FROM odds
|
|
WHERE
|
|
raw_odds @> $1::jsonb AND
|
|
is_active = true AND
|
|
source = 'b365api'
|
|
LIMIT 1
|
|
`
|
|
|
|
type GetRawOddsByIDRow struct {
|
|
ID int32
|
|
EventID pgtype.Text
|
|
RawOdds []byte
|
|
FetchedAt pgtype.Timestamp
|
|
}
|
|
|
|
func (q *Queries) GetRawOddsByID(ctx context.Context, dollar_1 []byte) (GetRawOddsByIDRow, error) {
|
|
row := q.db.QueryRow(ctx, GetRawOddsByID, dollar_1)
|
|
var i GetRawOddsByIDRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.EventID,
|
|
&i.RawOdds,
|
|
&i.FetchedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const InsertNonLiveOdd = `-- name: InsertNonLiveOdd :exec
|
|
INSERT INTO odds (
|
|
event_id,
|
|
fi,
|
|
raw_event_id,
|
|
market_type,
|
|
market_name,
|
|
market_category,
|
|
market_id,
|
|
header,
|
|
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,
|
|
true, 'b365api', now()
|
|
)
|
|
ON CONFLICT (event_id, market_id, header, name, handicap) DO UPDATE SET
|
|
odds_value = EXCLUDED.odds_value,
|
|
raw_odds = EXCLUDED.raw_odds,
|
|
market_type = EXCLUDED.market_type,
|
|
market_name = EXCLUDED.market_name,
|
|
market_category = EXCLUDED.market_category,
|
|
fetched_at = now(),
|
|
is_active = true,
|
|
source = 'b365api',
|
|
fi = EXCLUDED.fi,
|
|
raw_event_id = EXCLUDED.raw_event_id
|
|
`
|
|
|
|
type InsertNonLiveOddParams struct {
|
|
EventID pgtype.Text `json:"event_id"`
|
|
Fi pgtype.Text `json:"fi"`
|
|
RawEventID pgtype.Text `json:"raw_event_id"`
|
|
MarketType string `json:"market_type"`
|
|
MarketName pgtype.Text `json:"market_name"`
|
|
MarketCategory pgtype.Text `json:"market_category"`
|
|
MarketID pgtype.Text `json:"market_id"`
|
|
Header pgtype.Text `json:"header"`
|
|
Name pgtype.Text `json:"name"`
|
|
Handicap pgtype.Text `json:"handicap"`
|
|
OddsValue pgtype.Float8 `json:"odds_value"`
|
|
Section string `json:"section"`
|
|
Category pgtype.Text `json:"category"`
|
|
RawOdds []byte `json:"raw_odds"`
|
|
}
|
|
|
|
func (q *Queries) InsertNonLiveOdd(ctx context.Context, arg InsertNonLiveOddParams) error {
|
|
_, err := q.db.Exec(ctx, InsertNonLiveOdd,
|
|
arg.EventID,
|
|
arg.Fi,
|
|
arg.RawEventID,
|
|
arg.MarketType,
|
|
arg.MarketName,
|
|
arg.MarketCategory,
|
|
arg.MarketID,
|
|
arg.Header,
|
|
arg.Name,
|
|
arg.Handicap,
|
|
arg.OddsValue,
|
|
arg.Section,
|
|
arg.Category,
|
|
arg.RawOdds,
|
|
)
|
|
return err
|
|
}
|