// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.25.0 // source: batch.go package model import ( "context" "errors" "time" "github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5/pgtype" "github.com/shopspring/decimal" ) var ( ErrBatchAlreadyClosed = errors.New("batch already closed") ) const createOrUpdateCompetitions = `-- name: CreateOrUpdateCompetitions :batchexec INSERT INTO competitions ( slug, display_name, country_slug, competition_format, competition_type, picture_url, logo_url ) VALUES ($1, $2, $3, $4, $5, $6, $7) ON CONFLICT (slug) DO UPDATE SET display_name = EXCLUDED.display_name, competition_format = EXCLUDED.competition_format, competition_type = EXCLUDED.competition_type, picture_url = EXCLUDED.picture_url, logo_url = EXCLUDED.logo_url, country_slug = EXCLUDED.country_slug ` type CreateOrUpdateCompetitionsBatchResults struct { br pgx.BatchResults tot int closed bool } type CreateOrUpdateCompetitionsParams struct { Slug string DisplayName string CountrySlug string CompetitionFormat string CompetitionType string PictureUrl string LogoUrl string } func (q *Queries) CreateOrUpdateCompetitions(ctx context.Context, arg []CreateOrUpdateCompetitionsParams) *CreateOrUpdateCompetitionsBatchResults { batch := &pgx.Batch{} for _, a := range arg { vals := []interface{}{ a.Slug, a.DisplayName, a.CountrySlug, a.CompetitionFormat, a.CompetitionType, a.PictureUrl, a.LogoUrl, } batch.Queue(createOrUpdateCompetitions, vals...) } br := q.db.SendBatch(ctx, batch) return &CreateOrUpdateCompetitionsBatchResults{br, len(arg), false} } func (b *CreateOrUpdateCompetitionsBatchResults) Exec(f func(int, error)) { defer b.br.Close() for t := 0; t < b.tot; t++ { if b.closed { if f != nil { f(t, ErrBatchAlreadyClosed) } continue } _, err := b.br.Exec() if f != nil { f(t, err) } } } func (b *CreateOrUpdateCompetitionsBatchResults) Close() error { b.closed = true return b.br.Close() } const createOrUpdateCountries = `-- name: CreateOrUpdateCountries :batchexec INSERT INTO countries ( slug, code, display_name, three_letter_code, flag_flat_64_url, flag_flat_32_url, flag_round_64_url, flag_round_32_url ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) ON CONFLICT (slug) DO UPDATE SET code = EXCLUDED.code, display_name = EXCLUDED.display_name, three_letter_code = EXCLUDED.three_letter_code, flag_flat_64_url = EXCLUDED.flag_flat_64_url, flag_flat_32_url = EXCLUDED.flag_flat_32_url, flag_round_64_url = EXCLUDED.flag_round_64_url, flag_round_32_url = EXCLUDED.flag_round_32_url ` type CreateOrUpdateCountriesBatchResults struct { br pgx.BatchResults tot int closed bool } type CreateOrUpdateCountriesParams struct { Slug string Code string DisplayName string ThreeLetterCode string FlagFlat64Url string FlagFlat32Url string FlagRound64Url string FlagRound32Url string } func (q *Queries) CreateOrUpdateCountries(ctx context.Context, arg []CreateOrUpdateCountriesParams) *CreateOrUpdateCountriesBatchResults { batch := &pgx.Batch{} for _, a := range arg { vals := []interface{}{ a.Slug, a.Code, a.DisplayName, a.ThreeLetterCode, a.FlagFlat64Url, a.FlagFlat32Url, a.FlagRound64Url, a.FlagRound32Url, } batch.Queue(createOrUpdateCountries, vals...) } br := q.db.SendBatch(ctx, batch) return &CreateOrUpdateCountriesBatchResults{br, len(arg), false} } func (b *CreateOrUpdateCountriesBatchResults) Exec(f func(int, error)) { defer b.br.Close() for t := 0; t < b.tot; t++ { if b.closed { if f != nil { f(t, ErrBatchAlreadyClosed) } continue } _, err := b.br.Exec() if f != nil { f(t, err) } } } func (b *CreateOrUpdateCountriesBatchResults) Close() error { b.closed = true return b.br.Close() } const createOrUpdateFixtures = `-- name: CreateOrUpdateFixtures :batchexec INSERT INTO fixtures (slug, display_name, state, start_date, end_date, game_week) VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (slug) DO UPDATE SET display_name = $2, state = $3, start_date = $4, end_date = $5, game_week = $6 ` type CreateOrUpdateFixturesBatchResults struct { br pgx.BatchResults tot int closed bool } type CreateOrUpdateFixturesParams struct { Slug string DisplayName string State string StartDate pgtype.Timestamptz EndDate pgtype.Timestamptz GameWeek int32 } func (q *Queries) CreateOrUpdateFixtures(ctx context.Context, arg []CreateOrUpdateFixturesParams) *CreateOrUpdateFixturesBatchResults { batch := &pgx.Batch{} for _, a := range arg { vals := []interface{}{ a.Slug, a.DisplayName, a.State, a.StartDate, a.EndDate, a.GameWeek, } batch.Queue(createOrUpdateFixtures, vals...) } br := q.db.SendBatch(ctx, batch) return &CreateOrUpdateFixturesBatchResults{br, len(arg), false} } func (b *CreateOrUpdateFixturesBatchResults) Exec(f func(int, error)) { defer b.br.Close() for t := 0; t < b.tot; t++ { if b.closed { if f != nil { f(t, ErrBatchAlreadyClosed) } continue } _, err := b.br.Exec() if f != nil { f(t, err) } } } func (b *CreateOrUpdateFixturesBatchResults) Close() error { b.closed = true return b.br.Close() } const createOrUpdateGamePlayerScores = `-- name: CreateOrUpdateGamePlayerScores :batchexec INSERT INTO game_player_scores( game_id, player_slug, score, decisive_score, all_around_score, minutes_played, game_started, formation_place, live, on_game_sheet, reviewed, goal, assist, penalty_won, clearance_off_line, last_man_tackle, penalty_save, own_goal, red_card, error_lead_to_goal, penalty_conceded, yellow_card, fouls, fouled, clean_sheet, double_double, triple_double, triple_triple, error_lead_to_shot, saves, saved_shot_from_inside_box, good_high_claim, punches, diving_save, diving_catch, cross_not_claimed, goalkeeper_smother, six_second_violation, keeper_sweeper, goals_conceded, effective_clearance, won_tackle, blocked_cross, block, possession_lost, possession_won, duel_lost, duel_won, interception, accurate_pass, accurate_final_third_pass, accurate_long_ball, long_pass_into_opposition, missed_pass, shot_on_target, won_contest, big_chance_created, attempted_assist, penalty_area_entries, penalty_kick_missed, big_chance_missed) VALUES( $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31, $32,$33,$34,$35,$36,$37,$38,$39,$40,$41,$42,$43,$44,$45,$46,$47,$48,$49,$50,$51,$52,$53,$54,$55,$56,$57,$58,$59,$60, $61) ON CONFLICT (game_id, player_slug) DO UPDATE SET score = EXCLUDED.score, decisive_score = EXCLUDED.decisive_score, all_around_score = EXCLUDED.all_around_score, minutes_played = EXCLUDED.minutes_played, game_started = EXCLUDED.game_started, formation_place = EXCLUDED.formation_place, live = EXCLUDED.live, on_game_sheet = EXCLUDED.on_game_sheet, reviewed = EXCLUDED.reviewed, goal = EXCLUDED.goal, assist = EXCLUDED.assist, penalty_won = EXCLUDED.penalty_won, clearance_off_line = EXCLUDED.clearance_off_line, last_man_tackle = EXCLUDED.last_man_tackle, penalty_save = EXCLUDED.penalty_save, own_goal = EXCLUDED.own_goal, red_card = EXCLUDED.red_card, error_lead_to_goal = EXCLUDED.error_lead_to_goal, penalty_conceded = EXCLUDED.penalty_conceded, yellow_card = EXCLUDED.yellow_card, fouls = EXCLUDED.fouls, fouled = EXCLUDED.fouled, clean_sheet = EXCLUDED.clean_sheet, double_double = EXCLUDED.double_double, triple_double = EXCLUDED.triple_double, triple_triple = EXCLUDED.triple_triple, error_lead_to_shot = EXCLUDED.error_lead_to_shot, saves = EXCLUDED.saves, saved_shot_from_inside_box = EXCLUDED.saved_shot_from_inside_box, good_high_claim = EXCLUDED.good_high_claim, punches = EXCLUDED.punches, diving_save = EXCLUDED.diving_save, diving_catch = EXCLUDED.diving_catch, cross_not_claimed = EXCLUDED.cross_not_claimed, goalkeeper_smother = EXCLUDED.goalkeeper_smother, six_second_violation = EXCLUDED.six_second_violation, keeper_sweeper = EXCLUDED.keeper_sweeper, goals_conceded = EXCLUDED.goals_conceded, effective_clearance = EXCLUDED.effective_clearance, won_tackle = EXCLUDED.won_tackle, blocked_cross = EXCLUDED.blocked_cross, block = EXCLUDED.block, possession_lost = EXCLUDED.possession_lost, possession_won = EXCLUDED.possession_won, duel_lost = EXCLUDED.duel_lost, duel_won = EXCLUDED.duel_won, interception = EXCLUDED.interception, accurate_pass = EXCLUDED.accurate_pass, accurate_final_third_pass = EXCLUDED.accurate_final_third_pass, accurate_long_ball = EXCLUDED.accurate_long_ball, long_pass_into_opposition = EXCLUDED.long_pass_into_opposition, missed_pass = EXCLUDED.missed_pass, shot_on_target = EXCLUDED.shot_on_target, won_contest = EXCLUDED.won_contest, big_chance_created = EXCLUDED.big_chance_created, attempted_assist = EXCLUDED.attempted_assist, penalty_area_entries = EXCLUDED.penalty_area_entries, penalty_kick_missed = EXCLUDED.penalty_kick_missed, big_chance_missed = EXCLUDED.big_chance_missed ` type CreateOrUpdateGamePlayerScoresBatchResults struct { br pgx.BatchResults tot int closed bool } type CreateOrUpdateGamePlayerScoresParams struct { GameID string PlayerSlug string Score decimal.Decimal DecisiveScore decimal.Decimal AllAroundScore decimal.Decimal MinutesPlayed int32 GameStarted bool FormationPlace int32 Live bool OnGameSheet bool Reviewed bool Goal int32 Assist int32 PenaltyWon int32 ClearanceOffLine int32 LastManTackle int32 PenaltySave int32 OwnGoal int32 RedCard bool ErrorLeadToGoal int32 PenaltyConceded int32 YellowCard int32 Fouls int32 Fouled int32 CleanSheet bool DoubleDouble bool TripleDouble bool TripleTriple bool ErrorLeadToShot int32 Saves int32 SavedShotFromInsideBox int32 GoodHighClaim int32 Punches int32 DivingSave int32 DivingCatch int32 CrossNotClaimed int32 GoalkeeperSmother int32 SixSecondViolation int32 KeeperSweeper int32 GoalsConceded int32 EffectiveClearance int32 WonTackle int32 BlockedCross int32 Block int32 PossessionLost int32 PossessionWon int32 DuelLost int32 DuelWon int32 Interception int32 AccuratePass int32 AccurateFinalThirdPass int32 AccurateLongBall int32 LongPassIntoOpposition int32 MissedPass int32 ShotOnTarget int32 WonContest int32 BigChanceCreated int32 AttemptedAssist int32 PenaltyAreaEntries int32 PenaltyKickMissed int32 BigChanceMissed int32 } func (q *Queries) CreateOrUpdateGamePlayerScores(ctx context.Context, arg []CreateOrUpdateGamePlayerScoresParams) *CreateOrUpdateGamePlayerScoresBatchResults { batch := &pgx.Batch{} for _, a := range arg { vals := []interface{}{ a.GameID, a.PlayerSlug, a.Score, a.DecisiveScore, a.AllAroundScore, a.MinutesPlayed, a.GameStarted, a.FormationPlace, a.Live, a.OnGameSheet, a.Reviewed, a.Goal, a.Assist, a.PenaltyWon, a.ClearanceOffLine, a.LastManTackle, a.PenaltySave, a.OwnGoal, a.RedCard, a.ErrorLeadToGoal, a.PenaltyConceded, a.YellowCard, a.Fouls, a.Fouled, a.CleanSheet, a.DoubleDouble, a.TripleDouble, a.TripleTriple, a.ErrorLeadToShot, a.Saves, a.SavedShotFromInsideBox, a.GoodHighClaim, a.Punches, a.DivingSave, a.DivingCatch, a.CrossNotClaimed, a.GoalkeeperSmother, a.SixSecondViolation, a.KeeperSweeper, a.GoalsConceded, a.EffectiveClearance, a.WonTackle, a.BlockedCross, a.Block, a.PossessionLost, a.PossessionWon, a.DuelLost, a.DuelWon, a.Interception, a.AccuratePass, a.AccurateFinalThirdPass, a.AccurateLongBall, a.LongPassIntoOpposition, a.MissedPass, a.ShotOnTarget, a.WonContest, a.BigChanceCreated, a.AttemptedAssist, a.PenaltyAreaEntries, a.PenaltyKickMissed, a.BigChanceMissed, } batch.Queue(createOrUpdateGamePlayerScores, vals...) } br := q.db.SendBatch(ctx, batch) return &CreateOrUpdateGamePlayerScoresBatchResults{br, len(arg), false} } func (b *CreateOrUpdateGamePlayerScoresBatchResults) Exec(f func(int, error)) { defer b.br.Close() for t := 0; t < b.tot; t++ { if b.closed { if f != nil { f(t, ErrBatchAlreadyClosed) } continue } _, err := b.br.Exec() if f != nil { f(t, err) } } } func (b *CreateOrUpdateGamePlayerScoresBatchResults) Close() error { b.closed = true return b.br.Close() } const createOrUpdateGamePlayers = `-- name: CreateOrUpdateGamePlayers :batchexec INSERT INTO game_players( game_id, player_slug, status, team_slug) VALUES( $1, $2, $3, $4) ON CONFLICT (game_id, player_slug) DO UPDATE SET status = $3, team_slug = $4 ` type CreateOrUpdateGamePlayersBatchResults struct { br pgx.BatchResults tot int closed bool } type CreateOrUpdateGamePlayersParams struct { GameID string PlayerSlug string Status string TeamSlug string } func (q *Queries) CreateOrUpdateGamePlayers(ctx context.Context, arg []CreateOrUpdateGamePlayersParams) *CreateOrUpdateGamePlayersBatchResults { batch := &pgx.Batch{} for _, a := range arg { vals := []interface{}{ a.GameID, a.PlayerSlug, a.Status, a.TeamSlug, } batch.Queue(createOrUpdateGamePlayers, vals...) } br := q.db.SendBatch(ctx, batch) return &CreateOrUpdateGamePlayersBatchResults{br, len(arg), false} } func (b *CreateOrUpdateGamePlayersBatchResults) Exec(f func(int, error)) { defer b.br.Close() for t := 0; t < b.tot; t++ { if b.closed { if f != nil { f(t, ErrBatchAlreadyClosed) } continue } _, err := b.br.Exec() if f != nil { f(t, err) } } } func (b *CreateOrUpdateGamePlayersBatchResults) Close() error { b.closed = true return b.br.Close() } const createOrUpdateGames = `-- name: CreateOrUpdateGames :batchexec INSERT INTO games (id, date, coverage_status, low_coverage, minutes, period_type, scored, status, competition_slug, fixture_slug, away_team_slug, away_goals, away_extra_time_score, away_penalty_score, home_team_slug, home_goals, home_extra_time_score, home_penalty_score, winner_team_slug) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19) ON CONFLICT (id) DO UPDATE SET date = EXCLUDED.date, coverage_status = EXCLUDED.coverage_status, low_coverage = EXCLUDED.low_coverage, minutes = EXCLUDED.minutes, period_type = EXCLUDED.period_type, scored = EXCLUDED.scored, status = EXCLUDED.status, competition_slug = EXCLUDED.competition_slug, fixture_slug = EXCLUDED.fixture_slug, away_team_slug = EXCLUDED.away_team_slug, away_goals = EXCLUDED.away_goals, away_extra_time_score = EXCLUDED.away_extra_time_score, away_penalty_score = EXCLUDED.away_penalty_score, home_team_slug = EXCLUDED.home_team_slug, home_goals = EXCLUDED.home_goals, home_extra_time_score = EXCLUDED.home_extra_time_score, home_penalty_score = EXCLUDED.home_penalty_score, winner_team_slug = EXCLUDED.winner_team_slug ` type CreateOrUpdateGamesBatchResults struct { br pgx.BatchResults tot int closed bool } type CreateOrUpdateGamesParams struct { ID string Date pgtype.Timestamptz CoverageStatus string LowCoverage bool Minutes int32 PeriodType string Scored bool Status string CompetitionSlug string FixtureSlug string AwayTeamSlug string AwayGoals int32 AwayExtraTimeScore int32 AwayPenaltyScore int32 HomeTeamSlug string HomeGoals int32 HomeExtraTimeScore int32 HomePenaltyScore int32 WinnerTeamSlug *string } func (q *Queries) CreateOrUpdateGames(ctx context.Context, arg []CreateOrUpdateGamesParams) *CreateOrUpdateGamesBatchResults { batch := &pgx.Batch{} for _, a := range arg { vals := []interface{}{ a.ID, a.Date, a.CoverageStatus, a.LowCoverage, a.Minutes, a.PeriodType, a.Scored, a.Status, a.CompetitionSlug, a.FixtureSlug, a.AwayTeamSlug, a.AwayGoals, a.AwayExtraTimeScore, a.AwayPenaltyScore, a.HomeTeamSlug, a.HomeGoals, a.HomeExtraTimeScore, a.HomePenaltyScore, a.WinnerTeamSlug, } batch.Queue(createOrUpdateGames, vals...) } br := q.db.SendBatch(ctx, batch) return &CreateOrUpdateGamesBatchResults{br, len(arg), false} } func (b *CreateOrUpdateGamesBatchResults) Exec(f func(int, error)) { defer b.br.Close() for t := 0; t < b.tot; t++ { if b.closed { if f != nil { f(t, ErrBatchAlreadyClosed) } continue } _, err := b.br.Exec() if f != nil { f(t, err) } } } func (b *CreateOrUpdateGamesBatchResults) Close() error { b.closed = true return b.br.Close() } const createOrUpdatePlayers = `-- name: CreateOrUpdatePlayers :batchexec INSERT INTO players (slug, display_name, birth_date, country_slug, team_slug, domestic_league_slug, avatar_url, field_position, status, shirt_number) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) ON CONFLICT (slug) DO UPDATE SET display_name = $2, birth_date = $3, country_slug = $4, team_slug = $5, domestic_league_slug = $6, avatar_url = $7, field_position = $8, status = $9, shirt_number = $10 ` type CreateOrUpdatePlayersBatchResults struct { br pgx.BatchResults tot int closed bool } type CreateOrUpdatePlayersParams struct { Slug string DisplayName string BirthDate time.Time CountrySlug string TeamSlug *string DomesticLeagueSlug *string AvatarUrl string FieldPosition string Status string ShirtNumber int32 } func (q *Queries) CreateOrUpdatePlayers(ctx context.Context, arg []CreateOrUpdatePlayersParams) *CreateOrUpdatePlayersBatchResults { batch := &pgx.Batch{} for _, a := range arg { vals := []interface{}{ a.Slug, a.DisplayName, a.BirthDate, a.CountrySlug, a.TeamSlug, a.DomesticLeagueSlug, a.AvatarUrl, a.FieldPosition, a.Status, a.ShirtNumber, } batch.Queue(createOrUpdatePlayers, vals...) } br := q.db.SendBatch(ctx, batch) return &CreateOrUpdatePlayersBatchResults{br, len(arg), false} } func (b *CreateOrUpdatePlayersBatchResults) Exec(f func(int, error)) { defer b.br.Close() for t := 0; t < b.tot; t++ { if b.closed { if f != nil { f(t, ErrBatchAlreadyClosed) } continue } _, err := b.br.Exec() if f != nil { f(t, err) } } } func (b *CreateOrUpdatePlayersBatchResults) Close() error { b.closed = true return b.br.Close() } const createOrUpdateTeams = `-- name: CreateOrUpdateTeams :batchexec INSERT INTO teams (slug, display_name, country_slug, domestic_league_slug, short_name, picture_url, team_type) VALUES ($1, $2, $3, $4, $5, $6, $7) ON CONFLICT (slug) DO UPDATE SET display_name = $2, country_slug = $3, domestic_league_slug = $4, short_name = $5, picture_url = $6, team_type = $7 ` type CreateOrUpdateTeamsBatchResults struct { br pgx.BatchResults tot int closed bool } type CreateOrUpdateTeamsParams struct { Slug string DisplayName string CountrySlug string DomesticLeagueSlug *string ShortName string PictureUrl string TeamType string } func (q *Queries) CreateOrUpdateTeams(ctx context.Context, arg []CreateOrUpdateTeamsParams) *CreateOrUpdateTeamsBatchResults { batch := &pgx.Batch{} for _, a := range arg { vals := []interface{}{ a.Slug, a.DisplayName, a.CountrySlug, a.DomesticLeagueSlug, a.ShortName, a.PictureUrl, a.TeamType, } batch.Queue(createOrUpdateTeams, vals...) } br := q.db.SendBatch(ctx, batch) return &CreateOrUpdateTeamsBatchResults{br, len(arg), false} } func (b *CreateOrUpdateTeamsBatchResults) Exec(f func(int, error)) { defer b.br.Close() for t := 0; t < b.tot; t++ { if b.closed { if f != nil { f(t, ErrBatchAlreadyClosed) } continue } _, err := b.br.Exec() if f != nil { f(t, err) } } } func (b *CreateOrUpdateTeamsBatchResults) Close() error { b.closed = true return b.br.Close() }