112 lines
2.3 KiB
Go
112 lines
2.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 GetUpcomingEventIDs = `-- name: GetUpcomingEventIDs :many
|
|
SELECT id FROM events
|
|
WHERE is_live = false
|
|
`
|
|
|
|
func (q *Queries) GetUpcomingEventIDs(ctx context.Context) ([]string, error) {
|
|
rows, err := q.db.Query(ctx, GetUpcomingEventIDs)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []string
|
|
for rows.Next() {
|
|
var id string
|
|
if err := rows.Scan(&id); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, id)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
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
|
|
Fi pgtype.Text
|
|
RawEventID pgtype.Text
|
|
MarketType string
|
|
MarketName pgtype.Text
|
|
MarketCategory pgtype.Text
|
|
MarketID pgtype.Text
|
|
Header pgtype.Text
|
|
Name pgtype.Text
|
|
Handicap pgtype.Text
|
|
OddsValue pgtype.Float8
|
|
Section string
|
|
Category pgtype.Text
|
|
RawOdds []byte
|
|
}
|
|
|
|
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
|
|
}
|