mlb

package
v0.0.0-...-de618e6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2020 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BatchInsertGame

func BatchInsertGame(ctx context.Context, conn PGXDB, arr []*Game) (int64, error)

func BatchInsertGlUpload

func BatchInsertGlUpload(ctx context.Context, conn PGXDB, arr []*GlUpload) (int64, error)

func BatchInsertPitch

func BatchInsertPitch(ctx context.Context, conn PGXDB, arr []*Pitch) (int64, error)

func BatchInsertPitchSpatial

func BatchInsertPitchSpatial(ctx context.Context, conn PGXDB, arr []*PitchSpatial) (int64, error)

func BatchInsertPlay

func BatchInsertPlay(ctx context.Context, conn PGXDB, arr []*Play) (int64, error)

func BatchInsertPlayer

func BatchInsertPlayer(ctx context.Context, conn PGXDB, arr []*Player) (int64, error)

func InsertGame

func InsertGame(ctx context.Context, conn PGXDB, arr ...*Game) (int64, error)

func InsertGlUpload

func InsertGlUpload(ctx context.Context, conn PGXDB, arr ...*GlUpload) (int64, error)

func InsertPitch

func InsertPitch(ctx context.Context, conn PGXDB, arr ...*Pitch) (int64, error)

func InsertPitchSpatial

func InsertPitchSpatial(ctx context.Context, conn PGXDB, arr ...*PitchSpatial) (int64, error)

func InsertPlay

func InsertPlay(ctx context.Context, conn PGXDB, arr ...*Play) (int64, error)

func InsertPlayer

func InsertPlayer(ctx context.Context, conn PGXDB, arr ...*Player) (int64, error)

func Print

func Print(w io.Writer, arr []*Play) error

Types

type Game

type Game struct {
	GameID   int    `db:"game_id"`
	Season   int    `db:"season"`
	GameType string `db:"game_type"`
	HomeTeam int    `db:"home_team"`
	AwayTeam int    `db:"away_team"`
}

func GameByGameID

func GameByGameID(ctx context.Context, conn PGXDB, gameID int) (*Game, error)

type GlUpload

type GlUpload struct {
	Data       json.RawMessage `db:"data"`
	Checksum   *string         `db:"checksum"`
	UploadType string          `db:"upload_type"`
	UploadTime time.Time       `db:"upload_time"`
}

func GlUploadByChecksumUploadType

func GlUploadByChecksumUploadType(ctx context.Context, conn PGXDB, checksum *string, uploadType string) (*GlUpload, error)

type PGXDB

type PGXDB interface {
	Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
	SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
}

type Pitch

type Pitch struct {
	Season     int       `db:"season"`
	GameID     int       `db:"game_id"`
	PlayID     uuid.UUID `db:"play_id"`
	PitcherID  int       `db:"pitcher_id"`
	PitchHand  string    `db:"pitch_hand"`
	BatterID   int       `db:"batter_id"`
	BatSide    string    `db:"bat_side"`
	PfxX       []float64 `db:"pfx_x"`
	PfxY       []float64 `db:"pfx_y"`
	PfxZ       []float64 `db:"pfx_z"`
	PitchType  *string   `db:"pitch_type"`
	PlateXyzt  []float64 `db:"plate_xyzt"`
	CommitXyzt []float64 `db:"commit_xyzt"`
}

func PitchByGameID

func PitchByGameID(ctx context.Context, conn PGXDB, gameID int) ([]*Pitch, error)

func PitchByGameIDPlayID

func PitchByGameIDPlayID(ctx context.Context, conn PGXDB, gameID int, playID uuid.UUID) (*Pitch, error)

func PitchByPitchType

func PitchByPitchType(ctx context.Context, conn PGXDB, pitchType *string) ([]*Pitch, error)

func PitchByPitcherID

func PitchByPitcherID(ctx context.Context, conn PGXDB, pitcherID int) ([]*Pitch, error)

func PitchByPitcherIDBatSide

func PitchByPitcherIDBatSide(ctx context.Context, conn PGXDB, pitcherID int, batSide string) ([]*Pitch, error)

func PitchByPitcherIDPitchType

func PitchByPitcherIDPitchType(ctx context.Context, conn PGXDB, pitcherID int, pitchType *string) ([]*Pitch, error)

func PitchByPitcherIDPitchTypeBatSide

func PitchByPitcherIDPitchTypeBatSide(ctx context.Context, conn PGXDB, pitcherID int, pitchType *string, batSide string) ([]*Pitch, error)

func PitchBySeason

func PitchBySeason(ctx context.Context, conn PGXDB, season int) ([]*Pitch, error)

func PitchBySeasonPitcherIDPitchType

func PitchBySeasonPitcherIDPitchType(ctx context.Context, conn PGXDB, season int, pitcherID int, pitchType *string) ([]*Pitch, error)

func PitchBySeasonPitcherIDPitchTypeBatSide

func PitchBySeasonPitcherIDPitchTypeBatSide(ctx context.Context, conn PGXDB, season int, pitcherID int, pitchType *string, batSide string) ([]*Pitch, error)

type PitchSpatial

type PitchSpatial struct {
	GameID int       `db:"game_id"`
	PlayID uuid.UUID `db:"play_id"`
	T      float64   `db:"t"`
	Xyz    []float64 `db:"xyz"`
	M      string    `db:"m"`
	MXyz   int64     `db:"m_xyz"`
	MX     int       `db:"m_x"`
	MY     int       `db:"m_y"`
	MZ     int       `db:"m_z"`
	L01    int8      `db:"l01"`
	L02    int8      `db:"l02"`
	L03    int8      `db:"l03"`
	L04    int8      `db:"l04"`
	L05    int8      `db:"l05"`
	L06    int8      `db:"l06"`
	L07    int8      `db:"l07"`
	L08    int8      `db:"l08"`
	L09    int8      `db:"l09"`
	L10    int8      `db:"l10"`
	L11    int8      `db:"l11"`
	L12    int8      `db:"l12"`
	L13    int8      `db:"l13"`
	L14    int8      `db:"l14"`
	L15    int8      `db:"l15"`
	L16    int8      `db:"l16"`
	Tag    *string   `db:"tag"`
}

func PitchSpatialByGameIDPlayID

func PitchSpatialByGameIDPlayID(ctx context.Context, conn PGXDB, gameID int, playID uuid.UUID) ([]*PitchSpatial, error)

func PitchSpatialByGameIDPlayIDTag

func PitchSpatialByGameIDPlayIDTag(ctx context.Context, conn PGXDB, gameID int, playID uuid.UUID, tag *string) (*PitchSpatial, error)

func PitchSpatialByL01

func PitchSpatialByL01(ctx context.Context, conn PGXDB, l01 int8) ([]*PitchSpatial, error)

func PitchSpatialByL01L02L03L04

func PitchSpatialByL01L02L03L04(ctx context.Context, conn PGXDB, l01 int8, l02 int8, l03 int8, l04 int8) ([]*PitchSpatial, error)

func PitchSpatialByL01L02L03L04L05L06L07L08L09

func PitchSpatialByL01L02L03L04L05L06L07L08L09(ctx context.Context, conn PGXDB, l01 int8, l02 int8, l03 int8, l04 int8, l05 int8, l06 int8, l07 int8, l08 int8, l09 int8) ([]*PitchSpatial, error)

func PitchSpatialByL02

func PitchSpatialByL02(ctx context.Context, conn PGXDB, l02 int8) ([]*PitchSpatial, error)

func PitchSpatialByL03

func PitchSpatialByL03(ctx context.Context, conn PGXDB, l03 int8) ([]*PitchSpatial, error)

func PitchSpatialByL04

func PitchSpatialByL04(ctx context.Context, conn PGXDB, l04 int8) ([]*PitchSpatial, error)

func PitchSpatialByL05

func PitchSpatialByL05(ctx context.Context, conn PGXDB, l05 int8) ([]*PitchSpatial, error)

func PitchToSpatialPitch

func PitchToSpatialPitch(m *geom.Coord3, pitch *Pitch) []*PitchSpatial

func XYZTToSpatialPitch

func XYZTToSpatialPitch(m *geom.Coord3, gameID int, playID uuid.UUID, xyzt []float64, system string, tag *string) *PitchSpatial

type Play

type Play struct {
	GameID         int            `db:"game_id"`
	PlayID         uuid.UUID      `db:"play_id"`
	VenueID        int            `db:"venue_id"`
	GameIdx        int            `db:"game_idx"`
	AtBatIdx       int            `db:"at_bat_idx"`
	PlayIdx        int            `db:"play_idx"`
	StartTime      *time.Time     `db:"start_time"`
	EndTime        *time.Time     `db:"end_time"`
	Inning         int            `db:"inning"`
	Matchup        []int          `db:"matchup"`
	PreScore       []int          `db:"pre_score"`
	Score          []int          `db:"score"`
	PreRunner      RunnerMap      `db:"pre_runner"`
	Runner         RunnerMap      `db:"runner"`
	PreCount       []int          `db:"pre_count"`
	Count          []int          `db:"count"`
	PlayType       PlayType       `db:"play_type"`
	PlayResultType PlayResultType `db:"play_result_type"`
}

func PlayByGameIDPlayID

func PlayByGameIDPlayID(ctx context.Context, conn PGXDB, gameID int, playID uuid.UUID) (*Play, error)

type PlayResultType

type PlayResultType int
const (
	PlayResultTypeUnknown               PlayResultType = iota // err-unknown
	PlayResultTypeMissing                                     // err-missing
	PlayResultTypeBalk                                        // balk
	PlayResultTypeCaughtStealing                              // caught-stealing
	PlayResultTypeDefensiveIndifference                       // defensive-inference
	PlayResultTypeDefensiveSubstitution                       // defensive-substitution
	PlayResultTypeDefensiveSwitch                             // defensive-switch
	PlayResultTypeEjection                                    // ejection
	PlayResultTypeError                                       // error
	PlayResultTypeGameAdvisory                                // advisory
	PlayResultTypeInjury                                      // injury
	PlayResultTypeOffensiveSubstitution                       // offensive-substitution
	PlayResultTypeOtherAdvance                                // other-advance
	PlayResultTypeOtherOut                                    // other-out
	PlayResultTypePassedBall                                  // passed-ball
	PlayResultTypePickoffAttempt                              // pickoff-attempt
	PlayResultTypePickoffCaught                               // pickoff-caught
	PlayResultTypePickoffError                                // pickoff-error
	PlayResultTypePitcherSwitch                               // pitcher-switch
	PlayResultTypePitcherSubstitution                         // pitcher-substitution
	PlayResultTypeStolenBase                                  // stolen-base
	PlayResultTypeUmpireSubstitution                          // umpire-substitution
	PlayResultTypeWildPitch                                   // wild-pitch
	PlayResultTypePitchCalledStrike                           // pitch-called-strike
	PlayResultTypePitchSwingingStrike                         // pitch-swinging-strike
	PlayResultTypePitchCalledBall                             // pitch-called-ball
	PlayResultTypePitchFoul                                   // pitch-foul
	PlayResultTypePitchHitBatter                              // pitch-hit-by-pitch
	PlayResultTypeInPlayWithOuts                              // inplay-with-outs
	PlayResultTypeInPlayNoOuts                                // inplay-no-outs
	PlayResultTypeInPlayWithRuns                              // inplay-with-runs
)

func (PlayResultType) MarshalJSON

func (t PlayResultType) MarshalJSON() ([]byte, error)

func (PlayResultType) String

func (i PlayResultType) String() string

type PlayType

type PlayType int
const (
	PlayTypeUnknown PlayType = iota // err-unknown
	PlayTypeMissing                 // err-missing
	PlayTypeAction                  // action
	PlayTypePitch                   // pitch
	PlayTypePickoff                 // pickoff
	PlayTypeNoPitch                 // nopitch
)

func (PlayType) MarshalJSON

func (t PlayType) MarshalJSON() ([]byte, error)

func (PlayType) String

func (i PlayType) String() string

type Player

type Player struct {
	PlayerID  int    `db:"player_id"`
	NameFirst string `db:"name_first"`
	NameLast  string `db:"name_last"`
}

func PlayerByPlayerID

func PlayerByPlayerID(ctx context.Context, conn PGXDB, playerID int) (*Player, error)

type RunnerMap

type RunnerMap struct {
	Plate []int `db:"plate"`
	Base1 []int `db:"base1"`
	Base2 []int `db:"base2"`
	Base3 []int `db:"base3"`
	Out   []int `db:"out"`
	Score []int `db:"score"`
	// contains filtered or unexported fields
}

func (*RunnerMap) AssignTo

func (src *RunnerMap) AssignTo(dst interface{}) error

func (*RunnerMap) DecodeBinary

func (dst *RunnerMap) DecodeBinary(ci *pgtype.ConnInfo, src []byte) error

func (RunnerMap) EncodeBinary

func (src RunnerMap) EncodeBinary(ci *pgtype.ConnInfo, buf []byte) (newBuf []byte, err error)

func (*RunnerMap) Get

func (dst *RunnerMap) Get() interface{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL