// 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 DeleteAllCompanyOddsSetting = `-- name: DeleteAllCompanyOddsSetting :exec DELETE FROM company_odd_settings WHERE company_id = $1 ` func (q *Queries) DeleteAllCompanyOddsSetting(ctx context.Context, companyID int64) error { _, err := q.db.Exec(ctx, DeleteAllCompanyOddsSetting, companyID) return err } const DeleteCompanyOddsSettingByOddMarketID = `-- name: DeleteCompanyOddsSettingByOddMarketID :exec DELETE FROM company_odd_settings WHERE company_id = $1 AND odds_market_id = $2 ` type DeleteCompanyOddsSettingByOddMarketIDParams struct { CompanyID int64 `json:"company_id"` OddsMarketID int64 `json:"odds_market_id"` } func (q *Queries) DeleteCompanyOddsSettingByOddMarketID(ctx context.Context, arg DeleteCompanyOddsSettingByOddMarketIDParams) error { _, err := q.db.Exec(ctx, DeleteCompanyOddsSettingByOddMarketID, arg.CompanyID, arg.OddsMarketID) return err } const DeleteOddsForEvent = `-- name: DeleteOddsForEvent :exec DELETE FROM odds_market Where event_id = $1 ` func (q *Queries) DeleteOddsForEvent(ctx context.Context, eventID int64) 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, number_of_outcomes, 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.NumberOfOutcomes, &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 o.id, o.event_id, o.market_type, o.market_name, o.market_category, o.market_id, o.number_of_outcomes, o.default_is_active, o.fetched_at, o.expires_at, cos.company_id, COALESCE(cos.is_active, o.default_is_active) AS is_active, COALESCE(cos.custom_raw_odds, o.raw_odds) AS raw_odds, cos.updated_at FROM odds_market o LEFT JOIN company_odd_settings cos ON o.id = cos.odds_market_id AND 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"` } type GetAllOddsWithSettingsRow struct { ID int64 `json:"id"` EventID int64 `json:"event_id"` MarketType string `json:"market_type"` MarketName string `json:"market_name"` MarketCategory string `json:"market_category"` MarketID int64 `json:"market_id"` NumberOfOutcomes int64 `json:"number_of_outcomes"` DefaultIsActive bool `json:"default_is_active"` FetchedAt pgtype.Timestamp `json:"fetched_at"` ExpiresAt pgtype.Timestamp `json:"expires_at"` CompanyID pgtype.Int8 `json:"company_id"` IsActive bool `json:"is_active"` RawOdds []byte `json:"raw_odds"` UpdatedAt pgtype.Timestamp `json:"updated_at"` } func (q *Queries) GetAllOddsWithSettings(ctx context.Context, arg GetAllOddsWithSettingsParams) ([]GetAllOddsWithSettingsRow, 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 []GetAllOddsWithSettingsRow for rows.Next() { var i GetAllOddsWithSettingsRow if err := rows.Scan( &i.ID, &i.EventID, &i.MarketType, &i.MarketName, &i.MarketCategory, &i.MarketID, &i.NumberOfOutcomes, &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 GetOddByID = `-- name: GetOddByID :one SELECT id, event_id, market_type, market_name, market_category, market_id, raw_odds, number_of_outcomes, default_is_active, fetched_at, expires_at, is_monitored, is_live, status, source FROM odds_market_with_event WHERE id = $1 ` func (q *Queries) GetOddByID(ctx context.Context, id int64) (OddsMarketWithEvent, error) { row := q.db.QueryRow(ctx, GetOddByID, id) var i OddsMarketWithEvent err := row.Scan( &i.ID, &i.EventID, &i.MarketType, &i.MarketName, &i.MarketCategory, &i.MarketID, &i.RawOdds, &i.NumberOfOutcomes, &i.DefaultIsActive, &i.FetchedAt, &i.ExpiresAt, &i.IsMonitored, &i.IsLive, &i.Status, &i.Source, ) return i, err } const GetOddsByEventID = `-- name: GetOddsByEventID :many SELECT id, event_id, market_type, market_name, market_category, market_id, raw_odds, number_of_outcomes, 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 int64 `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.NumberOfOutcomes, &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, number_of_outcomes, 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 int64 `json:"market_id"` EventID int64 `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.NumberOfOutcomes, &i.DefaultIsActive, &i.FetchedAt, &i.ExpiresAt, &i.IsMonitored, &i.IsLive, &i.Status, &i.Source, ) return i, err } const GetOddsWithSettingsByEventID = `-- name: GetOddsWithSettingsByEventID :many SELECT o.id, o.event_id, o.market_type, o.market_name, o.market_category, o.market_id, o.number_of_outcomes, o.default_is_active, o.fetched_at, o.expires_at, cos.company_id, COALESCE(cos.is_active, o.default_is_active) AS is_active, COALESCE(cos.custom_raw_odds, o.raw_odds) AS raw_odds, cos.updated_at FROM odds_market o LEFT JOIN company_odd_settings cos ON o.id = cos.odds_market_id AND company_id = $2 WHERE event_id = $1 LIMIT $4 OFFSET $3 ` type GetOddsWithSettingsByEventIDParams struct { EventID int64 `json:"event_id"` CompanyID int64 `json:"company_id"` Offset pgtype.Int4 `json:"offset"` Limit pgtype.Int4 `json:"limit"` } type GetOddsWithSettingsByEventIDRow struct { ID int64 `json:"id"` EventID int64 `json:"event_id"` MarketType string `json:"market_type"` MarketName string `json:"market_name"` MarketCategory string `json:"market_category"` MarketID int64 `json:"market_id"` NumberOfOutcomes int64 `json:"number_of_outcomes"` DefaultIsActive bool `json:"default_is_active"` FetchedAt pgtype.Timestamp `json:"fetched_at"` ExpiresAt pgtype.Timestamp `json:"expires_at"` CompanyID pgtype.Int8 `json:"company_id"` IsActive bool `json:"is_active"` RawOdds []byte `json:"raw_odds"` UpdatedAt pgtype.Timestamp `json:"updated_at"` } func (q *Queries) GetOddsWithSettingsByEventID(ctx context.Context, arg GetOddsWithSettingsByEventIDParams) ([]GetOddsWithSettingsByEventIDRow, 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 []GetOddsWithSettingsByEventIDRow for rows.Next() { var i GetOddsWithSettingsByEventIDRow if err := rows.Scan( &i.ID, &i.EventID, &i.MarketType, &i.MarketName, &i.MarketCategory, &i.MarketID, &i.NumberOfOutcomes, &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 GetOddsWithSettingsByID = `-- name: GetOddsWithSettingsByID :one SELECT o.id, o.event_id, o.market_type, o.market_name, o.market_category, o.market_id, o.number_of_outcomes, o.default_is_active, o.fetched_at, o.expires_at, cos.company_id, COALESCE(cos.is_active, o.default_is_active) AS is_active, COALESCE(cos.custom_raw_odds, o.raw_odds) AS raw_odds, cos.updated_at FROM odds_market o LEFT JOIN company_odd_settings cos ON o.id = cos.odds_market_id AND company_id = $2 WHERE o.id = $1 ` type GetOddsWithSettingsByIDParams struct { ID int64 `json:"id"` CompanyID int64 `json:"company_id"` } type GetOddsWithSettingsByIDRow struct { ID int64 `json:"id"` EventID int64 `json:"event_id"` MarketType string `json:"market_type"` MarketName string `json:"market_name"` MarketCategory string `json:"market_category"` MarketID int64 `json:"market_id"` NumberOfOutcomes int64 `json:"number_of_outcomes"` DefaultIsActive bool `json:"default_is_active"` FetchedAt pgtype.Timestamp `json:"fetched_at"` ExpiresAt pgtype.Timestamp `json:"expires_at"` CompanyID pgtype.Int8 `json:"company_id"` IsActive bool `json:"is_active"` RawOdds []byte `json:"raw_odds"` UpdatedAt pgtype.Timestamp `json:"updated_at"` } func (q *Queries) GetOddsWithSettingsByID(ctx context.Context, arg GetOddsWithSettingsByIDParams) (GetOddsWithSettingsByIDRow, error) { row := q.db.QueryRow(ctx, GetOddsWithSettingsByID, arg.ID, arg.CompanyID) var i GetOddsWithSettingsByIDRow err := row.Scan( &i.ID, &i.EventID, &i.MarketType, &i.MarketName, &i.MarketCategory, &i.MarketID, &i.NumberOfOutcomes, &i.DefaultIsActive, &i.FetchedAt, &i.ExpiresAt, &i.CompanyID, &i.IsActive, &i.RawOdds, &i.UpdatedAt, ) return i, err } const GetOddsWithSettingsByMarketID = `-- name: GetOddsWithSettingsByMarketID :one SELECT o.id, o.event_id, o.market_type, o.market_name, o.market_category, o.market_id, o.number_of_outcomes, o.default_is_active, o.fetched_at, o.expires_at, cos.company_id, COALESCE(cos.is_active, o.default_is_active) AS is_active, COALESCE(cos.custom_raw_odds, o.raw_odds) AS raw_odds, cos.updated_at FROM odds_market o LEFT JOIN company_odd_settings cos ON o.id = cos.odds_market_id AND company_id = $3 WHERE market_id = $1 AND event_id = $2 ` type GetOddsWithSettingsByMarketIDParams struct { MarketID int64 `json:"market_id"` EventID int64 `json:"event_id"` CompanyID int64 `json:"company_id"` } type GetOddsWithSettingsByMarketIDRow struct { ID int64 `json:"id"` EventID int64 `json:"event_id"` MarketType string `json:"market_type"` MarketName string `json:"market_name"` MarketCategory string `json:"market_category"` MarketID int64 `json:"market_id"` NumberOfOutcomes int64 `json:"number_of_outcomes"` DefaultIsActive bool `json:"default_is_active"` FetchedAt pgtype.Timestamp `json:"fetched_at"` ExpiresAt pgtype.Timestamp `json:"expires_at"` CompanyID pgtype.Int8 `json:"company_id"` IsActive bool `json:"is_active"` RawOdds []byte `json:"raw_odds"` UpdatedAt pgtype.Timestamp `json:"updated_at"` } func (q *Queries) GetOddsWithSettingsByMarketID(ctx context.Context, arg GetOddsWithSettingsByMarketIDParams) (GetOddsWithSettingsByMarketIDRow, error) { row := q.db.QueryRow(ctx, GetOddsWithSettingsByMarketID, arg.MarketID, arg.EventID, arg.CompanyID) var i GetOddsWithSettingsByMarketIDRow err := row.Scan( &i.ID, &i.EventID, &i.MarketType, &i.MarketName, &i.MarketCategory, &i.MarketID, &i.NumberOfOutcomes, &i.DefaultIsActive, &i.FetchedAt, &i.ExpiresAt, &i.CompanyID, &i.IsActive, &i.RawOdds, &i.UpdatedAt, ) return i, err } const InsertOddsMarket = `-- name: InsertOddsMarket :exec INSERT INTO odds_market ( event_id, market_type, market_name, market_category, market_id, number_of_outcomes, raw_odds, fetched_at, expires_at ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9 ) 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, number_of_outcomes = EXCLUDED.number_of_outcomes, fetched_at = EXCLUDED.fetched_at, expires_at = EXCLUDED.expires_at ` type InsertOddsMarketParams struct { EventID int64 `json:"event_id"` MarketType string `json:"market_type"` MarketName string `json:"market_name"` MarketCategory string `json:"market_category"` MarketID int64 `json:"market_id"` NumberOfOutcomes int64 `json:"number_of_outcomes"` 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.NumberOfOutcomes, arg.RawOdds, arg.FetchedAt, arg.ExpiresAt, ) return err } const SaveOddSettings = `-- name: SaveOddSettings :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 SaveOddSettingsParams 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) SaveOddSettings(ctx context.Context, arg SaveOddSettingsParams) error { _, err := q.db.Exec(ctx, SaveOddSettings, arg.CompanyID, arg.OddsMarketID, arg.IsActive, arg.CustomRawOdds, ) return err } const UpdateGlobalOddsSetting = `-- name: UpdateGlobalOddsSetting :exec UPDATE odds_market SET default_is_active = COALESCE($2, default_is_active) WHERE id = $1 ` type UpdateGlobalOddsSettingParams struct { ID int64 `json:"id"` DefaultIsActive pgtype.Bool `json:"default_is_active"` } func (q *Queries) UpdateGlobalOddsSetting(ctx context.Context, arg UpdateGlobalOddsSettingParams) error { _, err := q.db.Exec(ctx, UpdateGlobalOddsSetting, arg.ID, arg.DefaultIsActive) return err }