// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.29.0 // source: events.sql package dbgen import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const DeleteEvent = `-- name: DeleteEvent :exec DELETE FROM events WHERE id = $1 ` func (q *Queries) DeleteEvent(ctx context.Context, id string) error { _, err := q.db.Exec(ctx, DeleteEvent, id) return err } const GetAllUpcomingEvents = `-- name: GetAllUpcomingEvents :many SELECT id, sport_id, match_name, home_team, away_team, home_team_id, away_team_id, home_kit_image, away_kit_image, league_id, league_name, start_time, score, match_minute, timer_status, added_time, match_period, is_live, status, fetched_at, source, default_is_active, default_is_featured, default_winning_upper_limit, is_monitored, league_cc FROM event_with_country WHERE start_time > now() AND is_live = false AND status = 'upcoming' ORDER BY start_time ASC ` func (q *Queries) GetAllUpcomingEvents(ctx context.Context) ([]EventWithCountry, error) { rows, err := q.db.Query(ctx, GetAllUpcomingEvents) if err != nil { return nil, err } defer rows.Close() var items []EventWithCountry for rows.Next() { var i EventWithCountry if err := rows.Scan( &i.ID, &i.SportID, &i.MatchName, &i.HomeTeam, &i.AwayTeam, &i.HomeTeamID, &i.AwayTeamID, &i.HomeKitImage, &i.AwayKitImage, &i.LeagueID, &i.LeagueName, &i.StartTime, &i.Score, &i.MatchMinute, &i.TimerStatus, &i.AddedTime, &i.MatchPeriod, &i.IsLive, &i.Status, &i.FetchedAt, &i.Source, &i.DefaultIsActive, &i.DefaultIsFeatured, &i.DefaultWinningUpperLimit, &i.IsMonitored, &i.LeagueCc, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetEventWithSettingByID = `-- name: GetEventWithSettingByID :one SELECT id, sport_id, match_name, home_team, away_team, home_team_id, away_team_id, home_kit_image, away_kit_image, league_id, league_name, start_time, score, match_minute, timer_status, added_time, match_period, is_live, status, fetched_at, source, default_is_active, default_is_featured, default_winning_upper_limit, is_monitored, company_id, is_active, is_featured, winning_upper_limit, updated_at, league_cc FROM event_with_settings WHERE id = $1 AND company_id = $2 AND is_live = false AND status = 'upcoming' LIMIT 1 ` type GetEventWithSettingByIDParams struct { ID string `json:"id"` CompanyID int64 `json:"company_id"` } func (q *Queries) GetEventWithSettingByID(ctx context.Context, arg GetEventWithSettingByIDParams) (EventWithSetting, error) { row := q.db.QueryRow(ctx, GetEventWithSettingByID, arg.ID, arg.CompanyID) var i EventWithSetting err := row.Scan( &i.ID, &i.SportID, &i.MatchName, &i.HomeTeam, &i.AwayTeam, &i.HomeTeamID, &i.AwayTeamID, &i.HomeKitImage, &i.AwayKitImage, &i.LeagueID, &i.LeagueName, &i.StartTime, &i.Score, &i.MatchMinute, &i.TimerStatus, &i.AddedTime, &i.MatchPeriod, &i.IsLive, &i.Status, &i.FetchedAt, &i.Source, &i.DefaultIsActive, &i.DefaultIsFeatured, &i.DefaultWinningUpperLimit, &i.IsMonitored, &i.CompanyID, &i.IsActive, &i.IsFeatured, &i.WinningUpperLimit, &i.UpdatedAt, &i.LeagueCc, ) return i, err } const GetEventsWithSettings = `-- name: GetEventsWithSettings :many SELECT id, sport_id, match_name, home_team, away_team, home_team_id, away_team_id, home_kit_image, away_kit_image, league_id, league_name, start_time, score, match_minute, timer_status, added_time, match_period, is_live, status, fetched_at, source, default_is_active, default_is_featured, default_winning_upper_limit, is_monitored, company_id, is_active, is_featured, winning_upper_limit, updated_at, league_cc FROM event_with_settings WHERE company_id = $1 AND start_time > now() AND is_live = false AND status = 'upcoming' AND ( league_id = $2 OR $2 IS NULL ) AND ( sport_id = $3 OR $3 IS NULL ) AND ( match_name ILIKE '%' || $4 || '%' OR league_name ILIKE '%' || $4 || '%' OR $4 IS NULL ) AND ( start_time < $5 OR $5 IS NULL ) AND ( start_time > $6 OR $6 IS NULL ) AND ( league_cc = $7 OR $7 IS NULL ) ORDER BY start_time ASC LIMIT $9 OFFSET $8 ` type GetEventsWithSettingsParams struct { CompanyID int64 `json:"company_id"` LeagueID pgtype.Int8 `json:"league_id"` SportID pgtype.Int4 `json:"sport_id"` Query pgtype.Text `json:"query"` LastStartTime pgtype.Timestamp `json:"last_start_time"` FirstStartTime pgtype.Timestamp `json:"first_start_time"` CountryCode pgtype.Text `json:"country_code"` Offset pgtype.Int4 `json:"offset"` Limit pgtype.Int4 `json:"limit"` } func (q *Queries) GetEventsWithSettings(ctx context.Context, arg GetEventsWithSettingsParams) ([]EventWithSetting, error) { rows, err := q.db.Query(ctx, GetEventsWithSettings, arg.CompanyID, arg.LeagueID, arg.SportID, arg.Query, arg.LastStartTime, arg.FirstStartTime, arg.CountryCode, arg.Offset, arg.Limit, ) if err != nil { return nil, err } defer rows.Close() var items []EventWithSetting for rows.Next() { var i EventWithSetting if err := rows.Scan( &i.ID, &i.SportID, &i.MatchName, &i.HomeTeam, &i.AwayTeam, &i.HomeTeamID, &i.AwayTeamID, &i.HomeKitImage, &i.AwayKitImage, &i.LeagueID, &i.LeagueName, &i.StartTime, &i.Score, &i.MatchMinute, &i.TimerStatus, &i.AddedTime, &i.MatchPeriod, &i.IsLive, &i.Status, &i.FetchedAt, &i.Source, &i.DefaultIsActive, &i.DefaultIsFeatured, &i.DefaultWinningUpperLimit, &i.IsMonitored, &i.CompanyID, &i.IsActive, &i.IsFeatured, &i.WinningUpperLimit, &i.UpdatedAt, &i.LeagueCc, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetExpiredEvents = `-- name: GetExpiredEvents :many SELECT id, sport_id, match_name, home_team, away_team, home_team_id, away_team_id, home_kit_image, away_kit_image, league_id, league_name, start_time, score, match_minute, timer_status, added_time, match_period, is_live, status, fetched_at, source, default_is_active, default_is_featured, default_winning_upper_limit, is_monitored, league_cc FROM event_with_country WHERE start_time < now() and ( status = $1 OR $1 IS NULL ) ORDER BY start_time ASC ` func (q *Queries) GetExpiredEvents(ctx context.Context, status pgtype.Text) ([]EventWithCountry, error) { rows, err := q.db.Query(ctx, GetExpiredEvents, status) if err != nil { return nil, err } defer rows.Close() var items []EventWithCountry for rows.Next() { var i EventWithCountry if err := rows.Scan( &i.ID, &i.SportID, &i.MatchName, &i.HomeTeam, &i.AwayTeam, &i.HomeTeamID, &i.AwayTeamID, &i.HomeKitImage, &i.AwayKitImage, &i.LeagueID, &i.LeagueName, &i.StartTime, &i.Score, &i.MatchMinute, &i.TimerStatus, &i.AddedTime, &i.MatchPeriod, &i.IsLive, &i.Status, &i.FetchedAt, &i.Source, &i.DefaultIsActive, &i.DefaultIsFeatured, &i.DefaultWinningUpperLimit, &i.IsMonitored, &i.LeagueCc, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetPaginatedUpcomingEvents = `-- name: GetPaginatedUpcomingEvents :many SELECT id, sport_id, match_name, home_team, away_team, home_team_id, away_team_id, home_kit_image, away_kit_image, league_id, league_name, start_time, score, match_minute, timer_status, added_time, match_period, is_live, status, fetched_at, source, default_is_active, default_is_featured, default_winning_upper_limit, is_monitored, league_cc FROM event_with_country WHERE start_time > now() AND is_live = false AND status = 'upcoming' AND ( league_id = $1 OR $1 IS NULL ) AND ( sport_id = $2 OR $2 IS NULL ) AND ( match_name ILIKE '%' || $3 || '%' OR league_name ILIKE '%' || $3 || '%' OR $3 IS NULL ) AND ( start_time < $4 OR $4 IS NULL ) AND ( start_time > $5 OR $5 IS NULL ) AND ( league_cc = $6 OR $6 IS NULL ) ORDER BY start_time ASC LIMIT $8 OFFSET $7 ` type GetPaginatedUpcomingEventsParams struct { LeagueID pgtype.Int8 `json:"league_id"` SportID pgtype.Int4 `json:"sport_id"` Query pgtype.Text `json:"query"` LastStartTime pgtype.Timestamp `json:"last_start_time"` FirstStartTime pgtype.Timestamp `json:"first_start_time"` CountryCode pgtype.Text `json:"country_code"` Offset pgtype.Int4 `json:"offset"` Limit pgtype.Int4 `json:"limit"` } func (q *Queries) GetPaginatedUpcomingEvents(ctx context.Context, arg GetPaginatedUpcomingEventsParams) ([]EventWithCountry, error) { rows, err := q.db.Query(ctx, GetPaginatedUpcomingEvents, arg.LeagueID, arg.SportID, arg.Query, arg.LastStartTime, arg.FirstStartTime, arg.CountryCode, arg.Offset, arg.Limit, ) if err != nil { return nil, err } defer rows.Close() var items []EventWithCountry for rows.Next() { var i EventWithCountry if err := rows.Scan( &i.ID, &i.SportID, &i.MatchName, &i.HomeTeam, &i.AwayTeam, &i.HomeTeamID, &i.AwayTeamID, &i.HomeKitImage, &i.AwayKitImage, &i.LeagueID, &i.LeagueName, &i.StartTime, &i.Score, &i.MatchMinute, &i.TimerStatus, &i.AddedTime, &i.MatchPeriod, &i.IsLive, &i.Status, &i.FetchedAt, &i.Source, &i.DefaultIsActive, &i.DefaultIsFeatured, &i.DefaultWinningUpperLimit, &i.IsMonitored, &i.LeagueCc, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const GetTotalCompanyEvents = `-- name: GetTotalCompanyEvents :one SELECT COUNT(*) FROM event_with_settings WHERE company_id = $1 AND is_live = false AND status = 'upcoming' AND ( league_id = $2 OR $2 IS NULL ) AND ( sport_id = $3 OR $3 IS NULL ) AND ( match_name ILIKE '%' || $4 || '%' OR league_name ILIKE '%' || $4 || '%' OR $4 IS NULL ) AND ( start_time < $5 OR $5 IS NULL ) AND ( start_time > $6 OR $6 IS NULL ) AND ( league_cc = $7 OR $7 IS NULL ) ` type GetTotalCompanyEventsParams struct { CompanyID int64 `json:"company_id"` LeagueID pgtype.Int8 `json:"league_id"` SportID pgtype.Int4 `json:"sport_id"` Query pgtype.Text `json:"query"` LastStartTime pgtype.Timestamp `json:"last_start_time"` FirstStartTime pgtype.Timestamp `json:"first_start_time"` CountryCode pgtype.Text `json:"country_code"` } func (q *Queries) GetTotalCompanyEvents(ctx context.Context, arg GetTotalCompanyEventsParams) (int64, error) { row := q.db.QueryRow(ctx, GetTotalCompanyEvents, arg.CompanyID, arg.LeagueID, arg.SportID, arg.Query, arg.LastStartTime, arg.FirstStartTime, arg.CountryCode, ) var count int64 err := row.Scan(&count) return count, err } const GetTotalEvents = `-- name: GetTotalEvents :one SELECT COUNT(*) FROM event_with_country WHERE is_live = false AND status = 'upcoming' AND ( league_id = $1 OR $1 IS NULL ) AND ( sport_id = $2 OR $2 IS NULL ) AND ( match_name ILIKE '%' || $3 || '%' OR league_name ILIKE '%' || $3 || '%' OR $3 IS NULL ) AND ( start_time < $4 OR $4 IS NULL ) AND ( start_time > $5 OR $5 IS NULL ) AND ( league_cc = $6 OR $6 IS NULL ) ` type GetTotalEventsParams struct { LeagueID pgtype.Int8 `json:"league_id"` SportID pgtype.Int4 `json:"sport_id"` Query pgtype.Text `json:"query"` LastStartTime pgtype.Timestamp `json:"last_start_time"` FirstStartTime pgtype.Timestamp `json:"first_start_time"` CountryCode pgtype.Text `json:"country_code"` } func (q *Queries) GetTotalEvents(ctx context.Context, arg GetTotalEventsParams) (int64, error) { row := q.db.QueryRow(ctx, GetTotalEvents, arg.LeagueID, arg.SportID, arg.Query, arg.LastStartTime, arg.FirstStartTime, arg.CountryCode, ) var count int64 err := row.Scan(&count) return count, err } const GetUpcomingByID = `-- name: GetUpcomingByID :one SELECT id, sport_id, match_name, home_team, away_team, home_team_id, away_team_id, home_kit_image, away_kit_image, league_id, league_name, start_time, score, match_minute, timer_status, added_time, match_period, is_live, status, fetched_at, source, default_is_active, default_is_featured, default_winning_upper_limit, is_monitored, league_cc FROM event_with_country WHERE id = $1 AND is_live = false AND status = 'upcoming' LIMIT 1 ` func (q *Queries) GetUpcomingByID(ctx context.Context, id string) (EventWithCountry, error) { row := q.db.QueryRow(ctx, GetUpcomingByID, id) var i EventWithCountry err := row.Scan( &i.ID, &i.SportID, &i.MatchName, &i.HomeTeam, &i.AwayTeam, &i.HomeTeamID, &i.AwayTeamID, &i.HomeKitImage, &i.AwayKitImage, &i.LeagueID, &i.LeagueName, &i.StartTime, &i.Score, &i.MatchMinute, &i.TimerStatus, &i.AddedTime, &i.MatchPeriod, &i.IsLive, &i.Status, &i.FetchedAt, &i.Source, &i.DefaultIsActive, &i.DefaultIsFeatured, &i.DefaultWinningUpperLimit, &i.IsMonitored, &i.LeagueCc, ) return i, err } const InsertEvent = `-- name: InsertEvent :exec INSERT INTO events ( id, sport_id, match_name, home_team, away_team, home_team_id, away_team_id, home_kit_image, away_kit_image, league_id, league_name, start_time, is_live, status, source ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15 ) ON CONFLICT (id) DO UPDATE SET sport_id = EXCLUDED.sport_id, match_name = EXCLUDED.match_name, home_team = EXCLUDED.home_team, away_team = EXCLUDED.away_team, home_team_id = EXCLUDED.home_team_id, away_team_id = EXCLUDED.away_team_id, home_kit_image = EXCLUDED.home_kit_image, away_kit_image = EXCLUDED.away_kit_image, league_id = EXCLUDED.league_id, league_name = EXCLUDED.league_name, league_cc = EXCLUDED.league_cc, start_time = EXCLUDED.start_time, score = EXCLUDED.score, match_minute = EXCLUDED.match_minute, timer_status = EXCLUDED.timer_status, added_time = EXCLUDED.added_time, match_period = EXCLUDED.match_period, is_live = EXCLUDED.is_live, source = EXCLUDED.source, fetched_at = now() ` type InsertEventParams struct { ID string `json:"id"` SportID int32 `json:"sport_id"` MatchName string `json:"match_name"` HomeTeam string `json:"home_team"` AwayTeam string `json:"away_team"` HomeTeamID int64 `json:"home_team_id"` AwayTeamID int64 `json:"away_team_id"` HomeKitImage string `json:"home_kit_image"` AwayKitImage string `json:"away_kit_image"` LeagueID int64 `json:"league_id"` LeagueName string `json:"league_name"` StartTime pgtype.Timestamp `json:"start_time"` IsLive bool `json:"is_live"` Status string `json:"status"` Source string `json:"source"` } func (q *Queries) InsertEvent(ctx context.Context, arg InsertEventParams) error { _, err := q.db.Exec(ctx, InsertEvent, arg.ID, arg.SportID, arg.MatchName, arg.HomeTeam, arg.AwayTeam, arg.HomeTeamID, arg.AwayTeamID, arg.HomeKitImage, arg.AwayKitImage, arg.LeagueID, arg.LeagueName, arg.StartTime, arg.IsLive, arg.Status, arg.Source, ) return err } const InsertEventSettings = `-- name: InsertEventSettings :exec INSERT INTO company_event_settings ( company_id, event_id, is_active, is_featured, winning_upper_limit ) VALUES ($1, $2, $3, $4, $5) ON CONFLICT(company_id, event_id) DO UPDATE SET is_active = EXCLUDED.is_active, is_featured = EXCLUDED.is_featured, winning_upper_limit = EXCLUDED.winning_upper_limit ` type InsertEventSettingsParams struct { CompanyID int64 `json:"company_id"` EventID string `json:"event_id"` IsActive pgtype.Bool `json:"is_active"` IsFeatured pgtype.Bool `json:"is_featured"` WinningUpperLimit pgtype.Int4 `json:"winning_upper_limit"` } func (q *Queries) InsertEventSettings(ctx context.Context, arg InsertEventSettingsParams) error { _, err := q.db.Exec(ctx, InsertEventSettings, arg.CompanyID, arg.EventID, arg.IsActive, arg.IsFeatured, arg.WinningUpperLimit, ) return err } const IsEventMonitored = `-- name: IsEventMonitored :one SELECT is_monitored FROM events WHERE id = $1 ` func (q *Queries) IsEventMonitored(ctx context.Context, id string) (bool, error) { row := q.db.QueryRow(ctx, IsEventMonitored, id) var is_monitored bool err := row.Scan(&is_monitored) return is_monitored, err } const ListLiveEvents = `-- name: ListLiveEvents :many SELECT id FROM event_with_country WHERE is_live = true ` func (q *Queries) ListLiveEvents(ctx context.Context) ([]string, error) { rows, err := q.db.Query(ctx, ListLiveEvents) 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 UpdateEventMonitored = `-- name: UpdateEventMonitored :exec UPDATE events SET is_monitored = $1 WHERE id = $2 ` type UpdateEventMonitoredParams struct { IsMonitored bool `json:"is_monitored"` ID string `json:"id"` } func (q *Queries) UpdateEventMonitored(ctx context.Context, arg UpdateEventMonitoredParams) error { _, err := q.db.Exec(ctx, UpdateEventMonitored, arg.IsMonitored, arg.ID) return err } const UpdateEventSettings = `-- name: UpdateEventSettings :exec UPDATE company_event_settings SET is_active = COALESCE($3, is_active), is_featured = COALESCE( $4, is_featured ), winning_upper_limit = COALESCE( $5, winning_upper_limit ) WHERE event_id = $1 AND company_id = $2 ` type UpdateEventSettingsParams struct { EventID string `json:"event_id"` CompanyID int64 `json:"company_id"` IsActive pgtype.Bool `json:"is_active"` IsFeatured pgtype.Bool `json:"is_featured"` WinningUpperLimit pgtype.Int4 `json:"winning_upper_limit"` } func (q *Queries) UpdateEventSettings(ctx context.Context, arg UpdateEventSettingsParams) error { _, err := q.db.Exec(ctx, UpdateEventSettings, arg.EventID, arg.CompanyID, arg.IsActive, arg.IsFeatured, arg.WinningUpperLimit, ) return err } const UpdateMatchResult = `-- name: UpdateMatchResult :exec UPDATE events SET score = $1, status = $2 WHERE id = $3 ` type UpdateMatchResultParams struct { Score pgtype.Text `json:"score"` Status string `json:"status"` ID string `json:"id"` } func (q *Queries) UpdateMatchResult(ctx context.Context, arg UpdateMatchResultParams) error { _, err := q.db.Exec(ctx, UpdateMatchResult, arg.Score, arg.Status, arg.ID) return err }