// 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 DeleteOddsForEvent = `-- name: DeleteOddsForEvent :exec DELETE FROM odds_market Where event_id = $1 ` func (q *Queries) DeleteOddsForEvent(ctx context.Context, eventID string) error { _, err := q.db.Exec(ctx, DeleteOddsForEvent, eventID) return err } const GetAllOdds = `-- name: GetAllOdds :many SELECT id, event_id, market_type, market_name, market_category, market_id, raw_odds, default_is_active, fetched_at, expires_at, is_monitored, is_live, status, source FROM odds_market_with_event LIMIT $2 OFFSET $1 ` type GetAllOddsParams struct { Offset pgtype.Int4 `json:"offset"` Limit pgtype.Int4 `json:"limit"` } func (q *Queries) GetAllOdds(ctx context.Context, arg GetAllOddsParams) ([]OddsMarketWithEvent, error) { rows, err := q.db.Query(ctx, GetAllOdds, arg.Offset, arg.Limit) if err != nil { return nil, err } defer rows.Close() var items []OddsMarketWithEvent for rows.Next() { var i OddsMarketWithEvent if err := rows.Scan( &i.ID, &i.EventID, &i.MarketType, &i.MarketName, &i.MarketCategory, &i.MarketID, &i.RawOdds, &i.DefaultIsActive, &i.FetchedAt, &i.ExpiresAt, &i.IsMonitored, &i.IsLive, &i.Status, &i.Source, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetAllOddsWithSettings = `-- name: GetAllOddsWithSettings :many SELECT id, event_id, market_type, market_name, market_category, market_id, odds_market_with_settings.raw_odds, default_is_active, fetched_at, expires_at, company_id, is_active, odds_market_with_settings.raw_odds, updated_at FROM odds_market_with_settings WHERE company_id = $1 LIMIT $3 OFFSET $2 ` type GetAllOddsWithSettingsParams struct { CompanyID int64 `json:"company_id"` Offset pgtype.Int4 `json:"offset"` Limit pgtype.Int4 `json:"limit"` } func (q *Queries) GetAllOddsWithSettings(ctx context.Context, arg GetAllOddsWithSettingsParams) ([]OddsMarketWithSetting, error) { rows, err := q.db.Query(ctx, GetAllOddsWithSettings, arg.CompanyID, arg.Offset, arg.Limit) if err != nil { return nil, err } defer rows.Close() var items []OddsMarketWithSetting for rows.Next() { var i OddsMarketWithSetting if err := rows.Scan( &i.ID, &i.EventID, &i.MarketType, &i.MarketName, &i.MarketCategory, &i.MarketID, &i.RawOdds, &i.DefaultIsActive, &i.FetchedAt, &i.ExpiresAt, &i.CompanyID, &i.IsActive, &i.RawOdds, &i.UpdatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetOddsByEventID = `-- name: GetOddsByEventID :many SELECT id, event_id, market_type, market_name, market_category, market_id, raw_odds, default_is_active, fetched_at, expires_at, is_monitored, is_live, status, source FROM odds_market_with_event WHERE event_id = $1 AND ( is_live = $2 OR $2 IS NULL ) AND ( status = $3 OR $3 IS NULL ) AND ( source = $4 OR $4 IS NULL ) LIMIT $6 OFFSET $5 ` type GetOddsByEventIDParams struct { EventID string `json:"event_id"` IsLive pgtype.Bool `json:"is_live"` Status pgtype.Text `json:"status"` Source pgtype.Text `json:"source"` Offset pgtype.Int4 `json:"offset"` Limit pgtype.Int4 `json:"limit"` } func (q *Queries) GetOddsByEventID(ctx context.Context, arg GetOddsByEventIDParams) ([]OddsMarketWithEvent, error) { rows, err := q.db.Query(ctx, GetOddsByEventID, arg.EventID, arg.IsLive, arg.Status, arg.Source, arg.Offset, arg.Limit, ) if err != nil { return nil, err } defer rows.Close() var items []OddsMarketWithEvent for rows.Next() { var i OddsMarketWithEvent if err := rows.Scan( &i.ID, &i.EventID, &i.MarketType, &i.MarketName, &i.MarketCategory, &i.MarketID, &i.RawOdds, &i.DefaultIsActive, &i.FetchedAt, &i.ExpiresAt, &i.IsMonitored, &i.IsLive, &i.Status, &i.Source, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetOddsByMarketID = `-- name: GetOddsByMarketID :one SELECT id, event_id, market_type, market_name, market_category, market_id, raw_odds, default_is_active, fetched_at, expires_at, is_monitored, is_live, status, source FROM odds_market_with_event WHERE market_id = $1 AND event_id = $2 ` type GetOddsByMarketIDParams struct { MarketID string `json:"market_id"` EventID string `json:"event_id"` } func (q *Queries) GetOddsByMarketID(ctx context.Context, arg GetOddsByMarketIDParams) (OddsMarketWithEvent, error) { row := q.db.QueryRow(ctx, GetOddsByMarketID, arg.MarketID, arg.EventID) var i OddsMarketWithEvent err := row.Scan( &i.ID, &i.EventID, &i.MarketType, &i.MarketName, &i.MarketCategory, &i.MarketID, &i.RawOdds, &i.DefaultIsActive, &i.FetchedAt, &i.ExpiresAt, &i.IsMonitored, &i.IsLive, &i.Status, &i.Source, ) return i, err } const GetOddsWithSettingsByEventID = `-- name: GetOddsWithSettingsByEventID :many SELECT id, event_id, market_type, market_name, market_category, market_id, odds_market_with_settings.raw_odds, default_is_active, fetched_at, expires_at, company_id, is_active, odds_market_with_settings.raw_odds, updated_at FROM odds_market_with_settings WHERE event_id = $1 AND company_id = $2 LIMIT $4 OFFSET $3 ` type GetOddsWithSettingsByEventIDParams struct { EventID string `json:"event_id"` CompanyID int64 `json:"company_id"` Offset pgtype.Int4 `json:"offset"` Limit pgtype.Int4 `json:"limit"` } func (q *Queries) GetOddsWithSettingsByEventID(ctx context.Context, arg GetOddsWithSettingsByEventIDParams) ([]OddsMarketWithSetting, error) { rows, err := q.db.Query(ctx, GetOddsWithSettingsByEventID, arg.EventID, arg.CompanyID, arg.Offset, arg.Limit, ) if err != nil { return nil, err } defer rows.Close() var items []OddsMarketWithSetting for rows.Next() { var i OddsMarketWithSetting if err := rows.Scan( &i.ID, &i.EventID, &i.MarketType, &i.MarketName, &i.MarketCategory, &i.MarketID, &i.RawOdds, &i.DefaultIsActive, &i.FetchedAt, &i.ExpiresAt, &i.CompanyID, &i.IsActive, &i.RawOdds, &i.UpdatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetOddsWithSettingsByMarketID = `-- name: GetOddsWithSettingsByMarketID :one SELECT id, event_id, market_type, market_name, market_category, market_id, odds_market_with_settings.raw_odds, default_is_active, fetched_at, expires_at, company_id, is_active, odds_market_with_settings.raw_odds, updated_at FROM odds_market_with_settings WHERE market_id = $1 AND event_id = $2 AND company_id = $3 ` type GetOddsWithSettingsByMarketIDParams struct { MarketID string `json:"market_id"` EventID string `json:"event_id"` CompanyID int64 `json:"company_id"` } func (q *Queries) GetOddsWithSettingsByMarketID(ctx context.Context, arg GetOddsWithSettingsByMarketIDParams) (OddsMarketWithSetting, error) { row := q.db.QueryRow(ctx, GetOddsWithSettingsByMarketID, arg.MarketID, arg.EventID, arg.CompanyID) var i OddsMarketWithSetting err := row.Scan( &i.ID, &i.EventID, &i.MarketType, &i.MarketName, &i.MarketCategory, &i.MarketID, &i.RawOdds, &i.DefaultIsActive, &i.FetchedAt, &i.ExpiresAt, &i.CompanyID, &i.IsActive, &i.RawOdds, &i.UpdatedAt, ) return i, err } const InsertOddSettings = `-- name: InsertOddSettings :exec INSERT INTO company_odd_settings ( company_id, odds_market_id, is_active, custom_raw_odds ) VALUES ($1, $2, $3, $4) ON CONFLICT (company_id, odds_market_id) DO UPDATE SET is_active = EXCLUDED.is_active, custom_raw_odds = EXCLUDED.custom_raw_odds ` type InsertOddSettingsParams struct { CompanyID int64 `json:"company_id"` OddsMarketID int64 `json:"odds_market_id"` IsActive pgtype.Bool `json:"is_active"` CustomRawOdds []byte `json:"custom_raw_odds"` } func (q *Queries) InsertOddSettings(ctx context.Context, arg InsertOddSettingsParams) error { _, err := q.db.Exec(ctx, InsertOddSettings, arg.CompanyID, arg.OddsMarketID, arg.IsActive, arg.CustomRawOdds, ) return err } const InsertOddsMarket = `-- name: InsertOddsMarket :exec INSERT INTO odds_market ( event_id, market_type, market_name, market_category, market_id, raw_odds, fetched_at, expires_at ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8 ) ON CONFLICT (event_id, market_id) DO UPDATE SET market_type = EXCLUDED.market_type, market_name = EXCLUDED.market_name, market_category = EXCLUDED.market_category, raw_odds = EXCLUDED.raw_odds, fetched_at = EXCLUDED.fetched_at, expires_at = EXCLUDED.expires_at ` type InsertOddsMarketParams struct { EventID string `json:"event_id"` MarketType string `json:"market_type"` MarketName string `json:"market_name"` MarketCategory string `json:"market_category"` MarketID string `json:"market_id"` RawOdds []byte `json:"raw_odds"` FetchedAt pgtype.Timestamp `json:"fetched_at"` ExpiresAt pgtype.Timestamp `json:"expires_at"` } func (q *Queries) InsertOddsMarket(ctx context.Context, arg InsertOddsMarketParams) error { _, err := q.db.Exec(ctx, InsertOddsMarket, arg.EventID, arg.MarketType, arg.MarketName, arg.MarketCategory, arg.MarketID, arg.RawOdds, arg.FetchedAt, arg.ExpiresAt, ) return err }