data

package
v0.0.0-...-52847de Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2016 License: GPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EjectionTypeNone              EjectionType = 0
	EjectionTypeSecondTechnical                = 1
	EjectionTypeSecondFlagrantOne              = 2
	EjectionTypeFlagrantTwo                    = 3
	EjectionTypeOther                          = 4
)
View Source
const (
	FoulTypePersonal                FoulType = 1
	FoulTypeShooting                         = 2
	FoulTypeLooseBall                        = 3
	FoulTypeOffensive                        = 4
	FoulTypeInbound                          = 5
	FoulTypeAwayFromPlay                     = 6
	FoulTypePunching                         = 8
	FoulTypeClearPath                        = 9
	FoulTypeTechnical                        = 11
	FoulTypeUnsportsmanlike                  = 12
	FoulTypeHangingTechnical                 = 13
	FoulTypeFlagrantOne                      = 14
	FoulTypeFlagrantTwo                      = 15
	FoulTypeTeamTechnical                    = 17
	FoulTypeDelay                            = 18
	FoulTypeTaunting                         = 19
	FoulTypeExcessTimeout                    = 25
	FoulTypeOffensiveCharge                  = 26
	FoulTypePersonalBlock                    = 27
	FoulTypePersonalTake                     = 28
	FoulTypeShootingBlock                    = 29
	FoulTypeTooManyPlayersTechnical          = 30
)
View Source
const (
	FreeThrowUnknown           FreeThrowType = 0
	FreeThrowOneOfOne                        = 10
	FreeThrowOneOfTwo                        = 11
	FreeThrowTwoOfTwo                        = 12
	FreeThrowOneOfThree                      = 13
	FreeThrowTwoOfThree                      = 14
	FreeThrowThreeOfThree                    = 15
	FreeThrowTechnical                       = 16
	FreeThrowFlagrantOneOfTwo                = 18
	FreeThrowFlagrantTwoOfTwo                = 19
	FreeThrowFlagrantOneOfOne                = 20
	FreeThrowTechincalOneOfTwo               = 21
	FreeThrowClearPathOneOfTwo               = 25
	FreeThrowClearPathTwoOfTwo               = 26
)
View Source
const (
	EventTypeOther        EventType = 0
	EventTypeMadeShot               = 1
	EventTypeMissedShot             = 2
	EventTypeFreeThrow              = 3
	EventTypeRebound                = 4
	EventTypeTurnover               = 5
	EventTypeFoul                   = 6
	EventTypeViolation              = 7
	EventTypeSubstitution           = 8
	EventTypeTimeout                = 9
	EventTypeJumpBall               = 10
	EventTypeEjection               = 11
	EventTypePeriodStart            = 12
	EventTypePeriodEnd              = 13
)
View Source
const (
	TimeoutTypeNone     TimeoutType = 0
	TimeoutTypeRegular              = 1
	TimeoutTypeShort                = 2
	TimeoutTypeOfficial             = 4
)
View Source
const (
	TurnoverUnknown              TurnoverType = 0
	TurnoverBadPass                           = 1
	TurnoverLostBall                          = 2
	TurnoverOutOfBounds                       = 3
	TurnoverTraveling                         = 4
	TurnoverFoul                              = 5
	TurnoverDoubleDribble                     = 6
	TurnoverDiscontinueDribble                = 7
	TurnoverThreeSecondViolation              = 8
	TurnoverFiveSecondViolation               = 9
	TurnoverEightSecondViolation              = 10
	TurnoverShotClock                         = 11
	TurnoverInbound                           = 12
	TurnoverBackcourt                         = 13
	TurnoverOffensiveGoaltending              = 15
	TurnoverIsolationViolation                = 16
	TurnoverLaneViolation                     = 17
	TurnoverJumpBallViolation                 = 18
	TurnoverKickedBall                        = 19
	TurnoverIllegalAssist                     = 20
	TurnoverPalming                           = 21
	TurnoverDoublePersonal                    = 23
	TurnoverStolenPass                        = 31
	TurnoverOppositeBasket                    = 32
	TurnoverPunchedBall                       = 33
	TurnoverSwingingElbows                    = 34
	TurnoverBasketFromBelow                   = 35
	TurnoverIllegalScreen                     = 36
	TurnoverOffensiveFoul                     = 37
	TurnoverFiveSecondInbound                 = 38
	TurnoverStepOutOfBounds                   = 39
	TurnoverOutOfBoundsLostBall               = 40
	TurnoverSteal                             = 41
	TurnoverTeam                              = 42
	TurnoverPlayerOutOfBounds                 = 43
	TurnoverTooManyPlayers                    = 44
	TurnoverOutOfBoundsBadPass                = 45
	TurnoverStealLostBall                     = 52
)

TODO(jackson): Fill in the gaps in the turnover table.

View Source
const (
	ViolationTypeNone                 ViolationType = 0
	ViolationTypeDelayOfGame                        = 1
	ViolationTypeDefensiveGoaltending               = 2
	ViolationTypeLane                               = 3
	ViolationTypeJumpBall                           = 4
	ViolationTypeKickedBall                         = 5
	ViolationTypeDoubleLane                         = 6
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BoxScore

type BoxScore struct {
	TeamStats   []*TeamStats   `json:"team"`
	PlayerStats []*PlayerStats `json:"player"`
}

BoxScore holds an individual game's box score.

func (*BoxScore) Player

func (box *BoxScore) Player(playerID int) *PlayerStats

Player returns the stats for the player with the given ID. If the player with the given ID did not play in the game, then nil is returned.

func (*BoxScore) Team

func (box *BoxScore) Team(teamID int) *TeamStats

Team returns the stats for the team with the given ID. If no team with the given ID played in the game, then nil is returned.

type Date

type Date time.Time

Date is a wrapper around a time.Time, but only displays the date portion when serialized as JSON.

func (Date) MarshalText

func (d Date) MarshalText() ([]byte, error)

func (*Date) Scan

func (d *Date) Scan(src interface{}) error

func (Date) String

func (d Date) String() string

func (Date) Value

func (d Date) Value() (driver.Value, error)

type EjectionType

type EjectionType int

TimeoutType describes the type of ejection.

func (EjectionType) MarshalText

func (et EjectionType) MarshalText() ([]byte, error)

func (EjectionType) String

func (et EjectionType) String() string

func (EjectionType) Value

func (et EjectionType) Value() (driver.Value, error)

type Event

type Event struct {
	GameID             GameID             `json:"game_id"`
	Number             int                `json:"number"`
	Type               EventType          `json:"type"`
	Period             int                `json:"period"`
	Score              *Score             `json:"score,omitempty"`
	PeriodTimeSeconds  int                `json:"period_time_secs"`
	WallClockString    string             `json:"wall_clock,omitempty"`
	Player1            *PlayerDescription `json:"player1,omitempty"`
	Player2            *PlayerDescription `json:"player2,omitempty"`
	Player3            *PlayerDescription `json:"player3,omitempty"`
	HomeDescription    *string            `json:"home_description,omitempty"`
	NeutralDescription *string            `json:"neutral_description,omitempty"`
	VisitorDescription *string            `json:"visitor_description,omitempty"`
	Shot               *Shot              `json:"shot,omitempty"`
}

Event describes an event that occurs within a game.

type EventType

type EventType int

EventType is an enum for the type of event that occurred in the game.

func (EventType) MarshalText

func (et EventType) MarshalText() ([]byte, error)

func (EventType) String

func (et EventType) String() string

func (EventType) Value

func (et EventType) Value() (driver.Value, error)

type Foul

type Foul struct {
	Type     FoulType
	Offender *PlayerDescription
}

type FoulType

type FoulType int

FoulType describes the type of foul. See http://www.nba.com/analysis/rules_12.html

func (FoulType) MarshalText

func (ft FoulType) MarshalText() ([]byte, error)

func (FoulType) String

func (ft FoulType) String() string

func (FoulType) Value

func (ft FoulType) Value() (driver.Value, error)

type FreeThrowType

type FreeThrowType int

FreeThrowType defines the type of free throw.

func (FreeThrowType) MarshalText

func (ft FreeThrowType) MarshalText() ([]byte, error)

func (FreeThrowType) String

func (ft FreeThrowType) String() string

func (FreeThrowType) Value

func (ft FreeThrowType) Value() (driver.Value, error)

type Game

type Game struct {
	ID                GameID     `json:"id,omitempty" db:"id"`
	Playoffs          bool       `json:"playoff,omitempty" db:"playoffs"`
	HomeTeamID        int        `json:"home_team_id" db:"home_team_id"`
	VisitorTeamID     int        `json:"visitor_team_id" db:"visitor_team_id"`
	Season            Season     `json:"season" db:"season"`
	Status            GameStatus `json:"status" db:"status"`
	LastMeetingGameID GameID     `json:"last_meeting_game_id" db:"last_meeting_game_id"`
}

Game holds basic information about a NBA game.

type GameDetails

type GameDetails struct {
	Game
	Date          Date          `json:"date" db:"time"`
	LengthMinutes int           `json:"length_minutes" db:"length_minutes"`
	Attendance    int           `json:"attendance" db:"attendance"`
	Officials     []*Official   `json:"officials" db:"-"`
	HomePoints    *PointSummary `json:"home_points,omitempty" db:"-"`
	VisitorPoints *PointSummary `json:"visitor_points,omitempty" db:"-"`
	LeadChanges   int           `json:"lead_changes" db:"lead_changes"`
	TimesTied     int           `json:"times_tied" db:"times_tied"`
}

GameDetails provides detailed information and summary of an NBA game.

type GameID

type GameID string

GameID holds a unique identifier for an NBA game. The identifier is unique across all seasons and teams.

func (GameID) IsPlayoff

func (id GameID) IsPlayoff() bool

IsPlayoff returns whether or not the game is a playoff game.

func (*GameID) Scan

func (id *GameID) Scan(src interface{}) error

func (GameID) String

func (id GameID) String() string

func (GameID) Value

func (id GameID) Value() (driver.Value, error)

type GameStatus

type GameStatus int

GameStatus indicates the status of a game.

const (
	// Unknown is used for unrecognized game status IDs.
	Unknown GameStatus = 0
	// Scheduled indicates that a game is scheduled but has not yet begun.
	Scheduled GameStatus = 1
	// Live indicates that a game is in progress.
	Live GameStatus = 2
	// Final indicates a Game's score is Final and the game has finished.
	Final GameStatus = 3
)

func (GameStatus) MarshalText

func (s GameStatus) MarshalText() ([]byte, error)

func (GameStatus) String

func (s GameStatus) String() string

func (GameStatus) Value

func (s GameStatus) Value() (driver.Value, error)

type HomeOrAway

type HomeOrAway bool

HomeOrAway indicates whether a game was home or away with respect to a team or player.

const (
	Home HomeOrAway = true
	Away HomeOrAway = false
)

func (HomeOrAway) MarshalText

func (h HomeOrAway) MarshalText() ([]byte, error)

func (HomeOrAway) String

func (h HomeOrAway) String() string

func (HomeOrAway) Value

func (h HomeOrAway) Value() (driver.Value, error)

type Official

type Official struct {
	ID           int    `json:"id" db:"id"`
	FirstName    string `json:"first_name" db:"first_name"`
	LastName     string `json:"last_name" db:"last_name"`
	JerseyNumber string `json:"jersey_number" db:"jersey_number"`
}

Official represents an NBA official.

type Officiated

type Officiated struct {
	GameID     GameID `json:"game_id" db:"game_id"`
	OfficialID int    `json:"official_id" db:"official_id"`
}

Officiated represents the fact that the given NBA official officiated the given NBA game.

type Player

type Player struct {
	ID              int          `json:"id" db:"id"`
	FirstName       string       `json:"first_name" db:"first_name"`
	LastName        string       `json:"last_name" db:"last_name"`
	RosterStatus    RosterStatus `json:"roster_status" db:"roster_status"`
	CareerStartYear string       `json:"career_start_year" db:"career_start"`
	CareerEndYear   string       `json:"career_end_year" db:"career_end"`
	PlayerCode      string       `json:"player_code" db:"-"`
}

Player holds basic, identifying information about an NBA player.

func (*Player) String

func (p *Player) String() string

type PlayerDescription

type PlayerDescription struct {
	ID     int    `json:"id"`
	Name   string `json:"name"`
	TeamID int    `json:"team_id"`
}

PlayerDescription summarizes a player.

type PlayerDetails

type PlayerDetails struct {
	PlayerID         int          `json:"id" db:"id"`
	FirstName        string       `json:"first_name" db:"first_name"`
	LastName         string       `json:"last_name" db:"last_name"`
	Birthdate        *Date        `json:"birthdate,omitempty" db:"birthdate"`
	School           string       `json:"school,omitempty" db:"school"`
	Country          string       `json:"country,omitempty" db:"country"`
	Height           int          `json:"height,omitempty" db:"height"`
	Weight           int          `json:"weight,omitempty" db:"weight"`
	SeasonExperience int          `json:"season_experience" db:"season_experience"`
	Jersey           string       `json:"jersey,omitempty" db:"jersey"`
	Position         string       `json:"position,omitempty" db:"position"`
	RosterStatus     RosterStatus `json:"roster_status" db:"roster_status"`
	TeamID           int          `json:"team_id" db:"team_id"`
	TeamName         string       `json:"team_name,omitempty" db:"-"`
	TeamAbbreviation string       `json:"team_abbreviation,omitempty" db:"team_abbreviation"`
	TeamCity         string       `json:"team_city,omitempty" db:"-"`
	CareerStartYear  string       `json:"career_start_year" db:"career_start"`
	CareerEndYear    string       `json:"career_end_year" db:"career_end"`
	DLeague          bool         `json:"dleague" db:"dleague"`
}

PlayerDetails contains detailed information about an NBA player.

type PlayerGameStats

type PlayerGameStats struct {
	PlayerID int    `json:"player_id" db:"player_id"`
	GameID   GameID `json:"game_id" db:"game_id"`
	TeamID   int    `json:"team_id" db:"team_id"`
	StatsID  int    `json:"stats_id" db:"stats_id"`
}

PlayerGameStats joins between the player, game and stats tables.

type PlayerStats

type PlayerStats struct {
	PlayerID   int    `json:"id" db:"player_id"`
	PlayerName string `json:"player_name" db:"-"`
	TeamID     int    `json:"team_id" db:"-"`
	Stats
}

PlayerStats contains a summary stats line about a player's performance. The time period of the stats depends on the context.

type PointSummary

type PointSummary struct {
	InPaint       int   `json:"in_paint"`
	SecondChance  int   `json:"second_chance"`
	FromBench     int   `json:"from_bench"`
	FirstQuarter  int   `json:"first_quarter"`
	SecondQuarter int   `json:"second_quarter"`
	ThirdQuarter  int   `json:"third_quarter"`
	FourthQuarter int   `json:"fourth_quarter"`
	Overtime      []int `json:"overtime"`
	Total         int   `json:"total"`
}

PointSummary provides aggregate team point statistics.

type RosterStatus

type RosterStatus int

RosterStatus indicates whether a player is active on a roster.

const (
	// Inactive indicates a player's roster status is inactive.
	Inactive RosterStatus = iota
	// Active indicates a player's roster status is active.
	Active
)

func (RosterStatus) MarshalText

func (rs RosterStatus) MarshalText() ([]byte, error)

type Score

type Score struct {
	Home    int `json:"home"`
	Visitor int `json:"visitor"`
}

type Season

type Season string

Season represents a season identifier. These may be returned by some API endpoints and used as parameters for others.

var (
	// CurrentSeason holds the season identifier for the current season. The season
	// switches starting on July 1st.
	CurrentSeason Season
)

func (Season) AddYears

func (s Season) AddYears(years int) Season

AddYears returns the season identifier the given number of years away. Years may be negative to go backwards.

func (Season) FallYear

func (s Season) FallYear() int

FallYear returns the beginning, fall year of this season. For ex, for "2014-15" it will return 2014.

func (Season) Next

func (s Season) Next() Season

Next returns the season after the given season.

func (Season) Previous

func (s Season) Previous() Season

Previous returns the season before the given season.

func (Season) SpringYear

func (s Season) SpringYear() int

FallYear returns the end, spring year of this season. For ex, for "2014-15" it will return 2015.

func (Season) String

func (s Season) String() string

String returns a string representation of the season.

func (*Season) UnmarshalText

func (s *Season) UnmarshalText(text []byte) error

func (Season) Value

func (s Season) Value() (driver.Value, error)

type Shot

type Shot struct {
	Player          *PlayerDescription `json:"player"`
	Made            bool               `json:"made"`
	PointsScored    int                `json:"points_scored"`
	PointsAttempted int                `json:"points_attempted"`
	Description     ShotDescription    `json:"description"`
}

Shot describes a shot attempt.

type ShotDescription

type ShotDescription []ShotType

ShotDescription describes a shot as a slice of ShotTypes.

func (ShotDescription) Is

func (sd ShotDescription) Is(typs ...ShotType) bool

Is checks if the shot description contains the provided types.

type ShotType

type ShotType int

ShotType is an enum of attributes of a shot attempt. Ex: was it a layup? a dunk? bank shot? put back? etc.

const (
	ShotTypeNone ShotType = iota
	ShotTypeJump
	ShotTypeHook
	ShotTypeLayup
	ShotTypeDunk
	ShotTypeRunning
	ShotTypeDriving
	ShotTypeAlleyOop
	ShotTypeReverse
	ShotTypeTurnaround
	ShotTypeFadeaway
	ShotTypeBank
	ShotTypeFingerRoll
	ShotTypePutBack
	ShotTypeFloating
	ShotTypePullUp
	ShotTypeStepBack
	ShotTypeTipIn
	ShotTypeCutting
	ShotTypeFollowUp
)

func (ShotType) MarshalText

func (st ShotType) MarshalText() ([]byte, error)

func (ShotType) String

func (st ShotType) String() string

func (ShotType) Value

func (st ShotType) Value() (driver.Value, error)

type Stats

type Stats struct {
	ID                     int      `json:"-" db:"id"`
	SecondsPlayed          int      `json:"seconds_played" db:"seconds_played"`
	FieldGoalsMade         int      `json:"field_goals_made" db:"field_goals_made"`
	FieldGoalsAttempted    int      `json:"field_goals_attempted" db:"field_goals_attempted"`
	FieldGoalPercentage    *float64 `json:"field_goal_percentage,omitempty" db:"-"`
	ThreePointersMade      int      `json:"three_pointers_made" db:"three_pointers_made"`
	ThreePointersAttempted int      `json:"three_pointers_attempted" db:"three_pointers_attempted"`
	ThreePointPercentage   *float64 `json:"three_point_percentage,omitempty" db:"-"`
	FreeThrowsMade         int      `json:"free_throws_made" db:"free_throws_made"`
	FreeThrowsAttempted    int      `json:"free_throws_attempted" db:"free_throws_attempted"`
	FreeThrowPercentage    *float64 `json:"free_throw_percentage,omitempty" db:"-"`
	OffensiveRebounds      int      `json:"offensive_rebounds" db:"offensive_rebounds"`
	DefensiveRebounds      int      `json:"defensive_rebounds" db:"defensive_rebounds"`
	Rebounds               int      `json:"rebounds" db:"-"`
	Assists                int      `json:"assists" db:"assists"`
	Steals                 int      `json:"steals" db:"steals"`
	Blocks                 int      `json:"blocks" db:"blocks"`
	Turnovers              int      `json:"turnovers" db:"turnovers"`
	PersonalFouls          int      `json:"personal_fouls" db:"personal_fouls"`
	Points                 int      `json:"points" db:"points"`
	PlusMinus              int      `json:"plus_minus" db:"plus_minus"`
}

Stats contains a stat line. These are sometimes incorporated into other structs that provide additional context about who the stats apply to and over what duration.

func (*Stats) Calculate

func (s *Stats) Calculate()

type Team

type Team struct {
	ID                 int     `json:"id" db:"id"`
	Abbreviation       *string `json:"abbreviation,omitempty" db:"abbreviation"`
	City               string  `json:"city" db:"city"`
	Name               string  `json:"name" db:"name"`
	StartYear          string  `json:"start_year" db:"start_year"`
	EndYear            string  `json:"end_year" db:"end_year"`
	Games              int     `json:"games" db:"games"`
	Wins               int     `json:"wins" db:"wins"`
	Losses             int     `json:"losses" db:"losses"`
	PlayOffAppearances int     `json:"playoff_appearances" db:"playoff_appearances"`
	DivisionTitles     int     `json:"division_titles" db:"division_titles"`
	ConferenceTitles   int     `json:"conference_titles" db:"conference_titles"`
	LeagueTitles       int     `json:"league_titles" db:"league_titles"`
}

Team represents an NBA team.

func (*Team) String

func (t *Team) String() string

type TeamGameStats

type TeamGameStats struct {
	TeamID  int    `json:"team_id" db:"team_id"`
	GameID  GameID `json:"game_id" db:"game_id"`
	StatsID int    `json:"stats_id" db:"stats_id"`
}

TeamGameStats joins between the team, game and stats tables.

type TeamStats

type TeamStats struct {
	TeamID           int    `json:"id" db:"team_id"`
	TeamName         string `json:"team_name" db:"-"`
	TeamAbbreviation string `json:"team_abbreviation" db:"-"`
	TeamCity         string `json:"team_city" db:"-"`
	Stats
}

TeamStats contains a summary stats line about a team's performance. The time period of the stats depends on the context.

type TimeoutType

type TimeoutType int

TimeoutType describes the type of a timeout.

func (TimeoutType) MarshalText

func (tt TimeoutType) MarshalText() ([]byte, error)

func (TimeoutType) String

func (tt TimeoutType) String() string

func (TimeoutType) Value

func (tt TimeoutType) Value() (driver.Value, error)

type TurnoverType

type TurnoverType int

TurnoverType defines the different types of turnovers.

func (TurnoverType) MarshalText

func (t TurnoverType) MarshalText() ([]byte, error)

func (TurnoverType) String

func (t TurnoverType) String() string

func (TurnoverType) Value

func (t TurnoverType) Value() (driver.Value, error)

type ViolationType

type ViolationType int

ViolationType describes the type of a violation.

func (ViolationType) MarshalText

func (vt ViolationType) MarshalText() ([]byte, error)

func (ViolationType) String

func (vt ViolationType) String() string

func (ViolationType) Value

func (vt ViolationType) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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