// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.29.0 // source: odds.sql package dbgen import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const GetALLPrematchOdds = `-- name: GetALLPrematchOdds :many SELECT 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 { EventID pgtype.Text `json:"event_id"` Fi pgtype.Text `json:"fi"` MarketType string `json:"market_type"` MarketName pgtype.Text `json:"market_name"` MarketCategory pgtype.Text `json:"market_category"` MarketID pgtype.Text `json:"market_id"` 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"` FetchedAt pgtype.Timestamp `json:"fetched_at"` Source pgtype.Text `json:"source"` IsActive pgtype.Bool `json:"is_active"` } 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.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 GetPaginatedPrematchOddsByUpcomingID = `-- name: GetPaginatedPrematchOddsByUpcomingID :many SELECT o.id, o.event_id, o.fi, o.market_type, o.market_name, o.market_category, o.market_id, o.name, o.handicap, o.odds_value, o.section, o.category, o.raw_odds, o.fetched_at, o.source, o.is_active FROM odds o JOIN events e ON o.fi = e.id WHERE e.id = $1 AND e.is_live = false AND e.status = 'upcoming' AND o.is_active = true AND o.source = 'b365api' LIMIT $3 OFFSET $2 ` type GetPaginatedPrematchOddsByUpcomingIDParams struct { ID string `json:"id"` Offset pgtype.Int4 `json:"offset"` Limit pgtype.Int4 `json:"limit"` } func (q *Queries) GetPaginatedPrematchOddsByUpcomingID(ctx context.Context, arg GetPaginatedPrematchOddsByUpcomingIDParams) ([]Odd, error) { rows, err := q.db.Query(ctx, GetPaginatedPrematchOddsByUpcomingID, arg.ID, arg.Offset, arg.Limit) 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.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 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 GetPrematchOddsRow struct { EventID pgtype.Text `json:"event_id"` Fi pgtype.Text `json:"fi"` MarketType string `json:"market_type"` MarketName pgtype.Text `json:"market_name"` MarketCategory pgtype.Text `json:"market_category"` MarketID pgtype.Text `json:"market_id"` 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"` FetchedAt pgtype.Timestamp `json:"fetched_at"` Source pgtype.Text `json:"source"` IsActive pgtype.Bool `json:"is_active"` } func (q *Queries) GetPrematchOdds(ctx context.Context) ([]GetPrematchOddsRow, error) { rows, err := q.db.Query(ctx, GetPrematchOdds) if err != nil { return nil, err } defer rows.Close() var items []GetPrematchOddsRow for rows.Next() { var i GetPrematchOddsRow if err := rows.Scan( &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 GetPrematchOddsByUpcomingID = `-- name: GetPrematchOddsByUpcomingID :many SELECT o.id, o.event_id, o.fi, o.market_type, o.market_name, o.market_category, o.market_id, o.name, o.handicap, o.odds_value, o.section, o.category, o.raw_odds, o.fetched_at, o.source, o.is_active FROM odds o JOIN events e ON o.fi = e.id WHERE e.id = $1 AND e.is_live = false AND e.status = 'upcoming' AND o.is_active = true AND o.source = 'b365api' ` func (q *Queries) GetPrematchOddsByUpcomingID(ctx context.Context, id string) ([]Odd, error) { rows, err := q.db.Query(ctx, GetPrematchOddsByUpcomingID, id) 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.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 GetRawOddsByMarketID = `-- name: GetRawOddsByMarketID :one SELECT id, market_name, handicap, raw_odds, fetched_at FROM odds WHERE market_id = $1 AND fi = $2 AND is_active = true AND source = 'b365api' ` type GetRawOddsByMarketIDParams struct { MarketID pgtype.Text `json:"market_id"` Fi pgtype.Text `json:"fi"` } type GetRawOddsByMarketIDRow struct { ID int32 `json:"id"` MarketName pgtype.Text `json:"market_name"` Handicap pgtype.Text `json:"handicap"` RawOdds []byte `json:"raw_odds"` FetchedAt pgtype.Timestamp `json:"fetched_at"` } func (q *Queries) GetRawOddsByMarketID(ctx context.Context, arg GetRawOddsByMarketIDParams) (GetRawOddsByMarketIDRow, error) { row := q.db.QueryRow(ctx, GetRawOddsByMarketID, arg.MarketID, arg.Fi) var i GetRawOddsByMarketIDRow err := row.Scan( &i.ID, &i.MarketName, &i.Handicap, &i.RawOdds, &i.FetchedAt, ) return i, err } const InsertNonLiveOdd = `-- name: InsertNonLiveOdd :exec INSERT INTO odds ( 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, name = EXCLUDED.name, handicap = EXCLUDED.handicap, fetched_at = EXCLUDED.fetched_at, is_active = EXCLUDED.is_active, source = EXCLUDED.source, fi = EXCLUDED.fi ` type InsertNonLiveOddParams struct { EventID pgtype.Text `json:"event_id"` Fi pgtype.Text `json:"fi"` MarketType string `json:"market_type"` MarketName pgtype.Text `json:"market_name"` MarketCategory pgtype.Text `json:"market_category"` MarketID pgtype.Text `json:"market_id"` 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"` IsActive pgtype.Bool `json:"is_active"` Source pgtype.Text `json:"source"` FetchedAt pgtype.Timestamp `json:"fetched_at"` } func (q *Queries) InsertNonLiveOdd(ctx context.Context, arg InsertNonLiveOddParams) error { _, err := q.db.Exec(ctx, InsertNonLiveOdd, arg.EventID, arg.Fi, arg.MarketType, arg.MarketName, arg.MarketCategory, arg.MarketID, arg.Name, arg.Handicap, arg.OddsValue, arg.Section, arg.Category, arg.RawOdds, arg.IsActive, arg.Source, arg.FetchedAt, ) return err }