firestore

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2022 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const GAMES_COLLECTION = "games"

GAMES_COLLECTION is the path to the games collection in Firestore.

View Source
const MODELS_COLLECTION = "models"
View Source
const MODEL_PERFORMANCES_COLLECTION = "model-performances"
View Source
const PERFORMANCES_COLLECTION = "performances"
View Source
const PICKERS_COLLECTION = "pickers"
View Source
const PICKS_COLLECTION = "picks"
View Source
const PREDICTIONS_COLLECTION = "predictions"
View Source
const SEASONS_COLLECTION = "seasons"
View Source
const SLATES_COLLECTION = "slates"
View Source
const SLATE_GAMES_COLLECTION = "games"
View Source
const STEAK_PREDICTIONS_COLLECTION = "streak-predictions"
View Source
const STREAK_PICKS_COLLECTION = "streak-picks"
View Source
const STREAK_TEAMS_REMAINING_COLLECTION = "streak-teams-remaining"
View Source
const TEAMS_COLLECTION = "teams"
View Source
const VENUES_COLLECTION = "venues"
View Source
const WEEKS_COLLECTION = "weeks"

WEEKS_COLLECTION is the path to the weeks collection in Firestore. It is a child of a season.

Variables

This section is empty.

Functions

func GetRemainingStreaks

func GetRemainingStreaks(ctx context.Context, season, week *firestore.DocumentRef) (strs map[string]StreakTeamsRemaining, refs map[string]*firestore.DocumentRef, err error)

GetRemainingStreaks looks up the remaining streaks for a given week, indexed by picker short name. If week is nil, returns new StreakTeamsRemaining objects for all pickers based off the season information.

Types

type Game

type Game struct {
	// HomeTeam is the nominal home team in the game.
	HomeTeam *fs.DocumentRef `firestore:"home_team"`

	// AwayTeam is the nominal away team in the game.
	AwayTeam *fs.DocumentRef `firestore:"away_team"`

	// StartTime is the nominal kickoff time of the game.
	StartTime time.Time `firestore:"start_time"`

	// StartTimeTBD is a flag that reports whether or not `StartTime` can be trusted.
	StartTimeTBD bool `firestore:"start_time_tbd"`

	// NeutralSite is true if the game is played at neither the home nor away team's venue.
	NeutralSite bool `firestore:"neutral_site"`

	// Venue is the venue of the game.
	Venue *fs.DocumentRef `firestore:"venue"`

	// HomePoints is the number of points earned by the home team at end of game.
	HomePoints *int `firestore:"home_points"`

	// AwayPoints is the number of points earned by the away team at end of game.
	AwayPoints *int `firestore:"away_points"`
}

Game is a ground truth game.

func GetGames

func GetGames(ctx context.Context, week *fs.DocumentRef) ([]Game, []*fs.DocumentRef, error)

GetGames returns a collection of games for a given week.

func GetGamesByStartTime

func GetGamesByStartTime(ctx context.Context, season *fs.DocumentRef, from, to time.Time) (games []Game, refs []*fs.DocumentRef, err error)

GetGamesByStartTime returns games that fall between two times (inclusive of lower bound, exclusive of upper).

func (Game) String

func (g Game) String() string

type GameRefsByMatchup

type GameRefsByMatchup map[Matchup]*fs.DocumentRef

GameRefsByMatchup is a struct for quick lookups of games by home/away teams and for correcting who is home, who is away, and whether the game is at a neutral site.

func NewGameRefsByMatchup

func NewGameRefsByMatchup(games []Game, refs []*fs.DocumentRef) GameRefsByMatchup

func (GameRefsByMatchup) LookupCorrectMatchup

func (g GameRefsByMatchup) LookupCorrectMatchup(m Matchup) (game *fs.DocumentRef, swap bool, wrongNeutral bool, ok bool)

func (GameRefsByMatchup) LookupTeam

func (g GameRefsByMatchup) LookupTeam(t string) (*fs.DocumentRef, bool)

type Matchup

type Matchup struct {
	Home    string
	Away    string
	Neutral bool
}

type Model

type Model struct {
	// System is a long descriptive name of the model.
	// It is human-readable, and is chiefly used to identify the model on ThePredictionTracker.com public-facing web pages.
	System string `firestore:"system,omitempty"`

	// ShortName is a short label given to the model.
	// It is not always human-readable, and is used to identify the model on ThePredictionTracker.com's downloadable CSV files.
	// All begin with the string "line".
	ShortName string `firestore:"short_name,omitempty"`
}

Model contains the information necessary to identify an NCAA football prediction model as defined by ThePredictionTracker.com.

func GetModels

func GetModels(ctx context.Context, client *fs.Client) ([]Model, []*fs.DocumentRef, error)

GetModels returns a collection of models.

type ModelPerformance

type ModelPerformance struct {
	// Rank is the weekly performance rank of the model as calculated by ThePredictionTracker.com using `PercentCorrect`.
	// The best performing model of the season to date is given `Rank = 1`.
	Rank int `firestore:"rank"`

	// PercentCorrect is the percent of games the model made a prediction for that were predicted correctly.
	// Because different models choose to predict only certain games every week, the denominator of this percentage
	// may not be consistent across models.
	PercentCorrect float64 `firestore:"pct_correct"`

	// PercentATS is the percent of games the model has predicted correctly against the opening line (Against The Spread).
	// This is only defined for models that predict the score of games rather than a boolean predicting who wins and who loses.
	// This is also not defined for the opening line model for obvious reasons.
	// For example of a correct pick against the opening line, imagine teams A and B are playing against each other and the opening
	// line is -5 (5 points in favor of team A). If the model predicts a spread of -7 (7 points in favor of team A) and the
	// final score of the game is 21-18 (team A wins by 3), then the model will be given a point for `PercentCorrect`, but not for
	// `PercentATS` because it predicted that team A would win by more than the opening line, but team A won by less than the opening line.
	PercentATS float64 `firestore:"pct_against_spread"`

	// MAE is the Mean Absolute Error in predicted score for games where the model has made a prediction.
	// The value is always non-negative.
	MAE float64 `firestore:"mae"`

	// MSE is the Mean Squared Error in predicted score for games where the model has made a prediction.
	// The value is always non-negative.
	MSE float64 `firestore:"mse"`

	// Bias is the mean error in predicted score for games where the model has made a prediction.
	// A positive value is a bias in favor of the home team (or the nominal home team if the game is played at a neutral site).
	Bias float64 `firestore:"bias"`

	// GamesPredicted are the number of games for which the model made a prediction. It is the denominator of the measures above.
	GamesPredicted int `firestore:"games"`

	// Wins is the number of correctly predicted game outcomes.
	Wins int `firestore:"suw"`

	// Losses is the number of incorrectly predicted game outcomes. Equal to `GamesPredicted - Wins`.
	Losses int `firestore:"sul"`

	// WinsATS are the wins "Against The Spread". It is the number of games in which the model correctly predicts whether the
	// difference in scores is on one side or the other of the opening line.
	// For example of a correct pick against the opening line, imagine teams A and B are playing against each other and the opening
	// line is -5 (5 points in favor of team A). If the model predicts a spread of -7 (7 points in favor of team A) and the
	// final score of the game is 21-18 (team A wins by 3), then the model will be given a point for `Wins`, but not for
	// `WinsATS` because it predicted that team A would win by more than the opening line, but team A won by less than the opening line.
	WinsATS int `firestore:"atsw"`

	// LossesATS are the losses "Against The Spread". It is the number of games in which the model incorrectly predicts whether the
	// difference in scores is on one side or the other of the opening line. Equal to `GamesPredicted - WinsATS`.
	LossesATS int `firestore:"atsl"`

	// StdDev is the standard deviation of the prediction errors.
	StdDev float64 `firestore:"std_dev"` // calculated

	// Model is a pointer to the Firestore model object it references for easy access.
	Model *fs.DocumentRef `firestore:"model"` // discovered
}

ModelPerformance contains information about how the model has performed to date during a given NCAA football season.

func GetMostRecentModelPerformances

func GetMostRecentModelPerformances(ctx context.Context, fsClient *fs.Client, week *fs.DocumentRef) ([]ModelPerformance, []*fs.DocumentRef, error)

GetMostRecentModelPerformances gets the most recent iteration of ModelPerformances for a given week.

func (ModelPerformance) String

func (mp ModelPerformance) String() string

String implements the Stringer interface.

type ModelPrediction

type ModelPrediction struct {
	// Model is a reference to the model that is making the prediction.
	Model *fs.DocumentRef `firestore:"model"`

	// HomeTeam is a reference to the Firestore Team the model thinks is the home team for the game.
	HomeTeam *fs.DocumentRef `firestore:"home_team"`

	// AwayTeam is a reference to the Firestore Team the model thinks is the away team for the game.
	AwayTeam *fs.DocumentRef `firestore:"away_team"`

	// NeutralSite flags if the model thinks the teams are playing at a neutral site.
	NeutralSite bool `firestore:"neutral"`

	// Spread is the predicted number of points in favor of `HomeTeam`.
	// Negative points reflect a prediction of `AwayTeam` winning.
	Spread float64 `firestore:"spread"`
}

ModelPrediction is a prediction made by a certain Model for a certain Game.

func GetPredictionByModel

func GetPredictionByModel(ctx context.Context, client *fs.Client, game *fs.DocumentRef, model *fs.DocumentRef) (ModelPrediction, *fs.DocumentRef, bool, error)

GetPredictionByModel looks up a prediction for a game by document ref.

func GetPredictions

func GetPredictions(ctx context.Context, client *fs.Client, game *fs.DocumentRef) ([]ModelPrediction, []*fs.DocumentRef, error)

GetPredictions returns a collection of predictions for a given game.

type ModelRefsByName

type ModelRefsByName map[string]*fs.DocumentRef

ModelRefsByName stores references to Model documents by either ShortName ("line...") or System name.

func NewModelRefsByShortName

func NewModelRefsByShortName(models []Model, refs []*fs.DocumentRef) ModelRefsByName

NewModelRefsByShortName creates a ModelRefsByName object ordered by ShortName.

func NewModelRefsBySystem

func NewModelRefsBySystem(models []Model, refs []*fs.DocumentRef) ModelRefsByName

NewModelRefsBySystem creates a ModelRefsByName object ordered by System. TODO: combine with above using interface.

func (ModelRefsByName) ReverseMap

func (m ModelRefsByName) ReverseMap() map[*fs.DocumentRef]string

type ModelTeamPoints

type ModelTeamPoints struct {
	// Model is a reference to the model that generates these scores.
	Model *fs.DocumentRef `firestore:"model"`

	// Team is a reference to the team.
	Team *fs.DocumentRef `firestore:"team"`

	// Points are the predicted points against an average team at a neutral site.
	Points float64 `firestore:"points"`

	// HomeAdvantage are the number of points added to the predicted points if this team is the home team.
	HomeAdvantage float64 `firestore:"home_advantage"`
}

ModelTeamPoints represents a modeled number of points that a given team is expected to score against an average opponent. Some models model the team's scoring potential directly rather than the spread of a given game. This is extremely useful for predicting the spread of unscheduled or hypothetical games that other models do not attempt to predict. Only Sagarin and FPI models team scoring potential directly.

func (ModelTeamPoints) String

func (mp ModelTeamPoints) String() string

String implements the Stringer interface.

type NoSlateError

type NoSlateError string

func (NoSlateError) Error

func (e NoSlateError) Error() string

type NoStreakPickError

type NoStreakPickError string

func (NoStreakPickError) Error

func (f NoStreakPickError) Error() string

type NoStreakTeamsRemaining

type NoStreakTeamsRemaining struct {
	PickerID string
	WeekID   string
}

func (NoStreakTeamsRemaining) Error

func (f NoStreakTeamsRemaining) Error() string

type NoWeekError

type NoWeekError int

func (NoWeekError) Error

func (e NoWeekError) Error() string

type Pick

type Pick struct {
	// SlateGame is a reference to the picked game in the slate.
	SlateGame *firestore.DocumentRef `firestore:"game"`

	// ModelPrediction is a reference to the spread from the model used to make the pick
	ModelPrediction *firestore.DocumentRef `firestore:"model_prediction"`

	// PickedTeam is the Team the Picker picked, regardless of the model output. Can be nil if this pick is for a "superdog" game and the underdog was not picked.
	PickedTeam *firestore.DocumentRef `firestore:"pick"`

	// PredictedSpread is the spread as predicted by the selected model.
	PredictedSpread float64 `firestore:"predicted_spread"`

	// PredictedProbability is the probability the pick is correct (including possible noisy spread adjustments).
	PredictedProbability float64 `firestore:"predicted_probability"`

	// Timestamp is the time the picks were written to Firestore.
	Timestamp time.Time `firestore:"timestamp,serverTimestamp"`

	// Picker is a reference to the picker who made the picks.
	Picker *firestore.DocumentRef `firestore:"picker"`
}

Pick is a pick on a game. See: SlateGame, ModelPrediction, and Team for references.

func GetPicks

func GetPicks(ctx context.Context, weekRef, pickerRef *firestore.DocumentRef) (picks []Pick, pickRefs []*firestore.DocumentRef, err error)

GetPicks gets a picker's picks for a given week.

func (Pick) BuildSlateRow

func (p Pick) BuildSlateRow(ctx context.Context) ([]string, error)

BuildSlateRow fills out the remaining 4 cells for a pick in a slate.

func (*Pick) FillOut

func (p *Pick) FillOut(game Game, perf ModelPerformance, pred ModelPrediction, predRef *firestore.DocumentRef, spread int)

FillOut uses game and model performance information to fill out a pick

func (Pick) String

func (p Pick) String() string

String implements Stringer interface

type Picker

type Picker struct {
	// Name is the picker's full name.
	Name string `firestore:"name"`

	// LukeName is the picker's name as used in the slates and recap emails.
	LukeName string `firestore:"name_luke"`

	// Joined is a timestamp marking when the picker joined Pick 'Em.
	Joined time.Time `firestore:"joined"`
}

Picker represents a picker in the datastore.

func GetPickerByLukeName

func GetPickerByLukeName(ctx context.Context, client *firestore.Client, name string) (Picker, *firestore.DocumentRef, error)

GetPickerByLukeName does what it purports to do.

func GetPickers

func GetPickers(ctx context.Context, client *firestore.Client) ([]Picker, []*firestore.DocumentRef, error)

GetPickers gets all pickers in the datastore.

func (*Picker) UnmarshalText

func (p *Picker) UnmarshalText(text []byte) error

UnmarshalText implements the TextUnmarshaler interface

type PickerNotFound

type PickerNotFound string

func (PickerNotFound) Error

func (e PickerNotFound) Error() string

type SagarinModelParameters

type SagarinModelParameters struct {
	// Timestamp is the time the scraped model parameters were saved to Firestore.
	Timestamp time.Time `firestore:"timestamp,serverTimestamp"`

	// TimeDownload is the time the model parameters were downloaded
	TimeDownloaded time.Time `firestore:"time_downloaded,omitempty"`

	// URL is the URL that was scraped
	URL string `firestore:"url_scraped,omitempty"`

	// RatingHomeAdvantage is the number of points the home team for a given contest should be given if using the default "ratings" method for prediction.
	RatingHomeAdvantage float64 `firestore:"home_advantage_rating"`

	// PointsHomeAdvantage is the number of points the home team for a given contest should be given if using the "points-only" method for prediction.
	PointsHomeAdvantage float64 `firestore:"home_advantage_points"`

	// GoldenMeanHomeAdvantage is the number of points the home team for a given contest should be given if using the "golden mean" method for prediction.
	GoldenMeanHomeAdvantage float64 `firestore:"home_advantage_golden_mean"`

	// RecentHomeAdvantage is the number of points the home team for a given contest should be given if using the "recent" method for prediction.
	RecentHomeAdvantage float64 `firestore:"home_advantage_recent"`
}

SagarinModelParameters represents Sagarin home field advantages for one scraping of Sagarin rankings.

type SagarinRating

type SagarinRating struct {
	// Team is a reference to the Firestore document of the team to which these ratings apply.
	Team *firestore.DocumentRef `firestore:"team"`

	// Rating is the number of points this team is predicted to score against an average NCAA Division I-A team at a neutral site using the default "ratings" method for prediction.
	Rating float64 `firestore:"rating"`

	// Points is the number of points this team is predicted to score against an average NCAA Division I-A team at a neutral site using the "points-only" method for prediction.
	Points float64 `firestore:"points"`

	// GoldenMean is the number of points this team is predicted to score against an average NCAA Division I-A team at a neutral site using the "golden mean" method for prediction.
	GoldenMean float64 `firestore:"golden_mean"`

	// Recent is the number of points this team is predicted to score against an average NCAA Division I-A team at a neutral site using the "recent" method for prediction.
	Recent float64 `firestore:"recent"`
}

SagarinRating represents a team's Sagarin ratings in Firestore.

type Schedule

type Schedule struct {
	// Team is a reference to the team this schedule represents.
	Team *firestore.DocumentRef `firestore:"team"`

	// RelativeLocations are the locations relative to `Team`. Values are:
	// * 2: this game takes place in the home stadium of `Team`.
	// * 1: this game takes place at a neutral site close to `Team`'s home.
	// * 0: this game takes place at a truly neutral site.
	// * -1: this game takes place at a neutral site close to the opponent's home.
	// * -2: this game takes place in the opponent's stadium.
	// These are in schedule order.
	RelativeLocations []int `firestore:"locales"`

	// Opponents are references to teams that `Team` is playing. They are in schedule order.
	Opponents []*firestore.DocumentRef `firestore:"opponents"`
}

Schedule is a team's schedule in Firestore format

type Season

type Season struct {
	// Year acts like a name for the season. It is the year that the season begins.
	Year int `firestore:"year"`

	// StartTime is a nominal time when the season begins. It's typically kickoff of the first game of the season.
	StartTime time.Time `firestore:"start_time"`

	// Pickers is a map of LukeNames to references to Picker documents in Firestore. These are the pickers who are registered to play this season.
	Pickers map[string]*firestore.DocumentRef `firestore:"pickers"`

	// StreakTeams is an array of teams available for the BTS competition.
	StreakTeams []*firestore.DocumentRef `firestore:"streak_teams"`

	// StreakPickTypes is an array of pick types available for the BTS competition.
	// The indices of the array represent the following:
	//   0: the number of bye weeks
	//   1: the number of single-team pick weeks
	//   2: the number of double-down pick weeks
	//   ...
	StreakPickTypes []int `firestore:"streak_pick_types"`
}

Season represents a Pick 'Em season.

func GetSeason

func GetSeason(ctx context.Context, client *firestore.Client, year int) (Season, *firestore.DocumentRef, error)

GetSeason gets the season defined by `year`. If `year<0`, the most recent season (by `start_time`) is returned.

func GetSeasons

func GetSeasons(ctx context.Context, client *firestore.Client) ([]Season, []*firestore.DocumentRef, error)

GetSeasons gets all seasons

type SeasonSchedule

type SeasonSchedule struct {
	// Season is a reference to the season.
	Season *firestore.DocumentRef `firestore:"season"`

	// Timestamp is the time this document is written to the server.
	Timestamp time.Time `firestore:"timestamp,serverTimestamp"`
}

SeasonSchedule represents a document in firestore that contains team schedules

type Slate

type Slate struct {

	// Created is the creation timestamp of the slate.
	Created time.Time `firestore:"created"`

	// Parsed is the parse timestamp of the slate.
	Parsed time.Time `firestore:"parsed,serverTimestamp"`

	// FileName is the full name of the parsed slate file. May be either a string representing a file location or a URL with a gs:// schema representing a Google Cloud Storage location.
	FileName string `firestore:"file"`
}

Slate represents how a slate is stored in Firestore. Slates contain a collection of SlateGames.

type SlateGame

type SlateGame struct {
	// Row is the row in which the game appeared in the slate.
	Row int `firestore:"row"`

	// Game is a references to the actual game picked.
	Game *fs.DocumentRef `firestore:"game"`

	// HomeRank is the ranking of the _true_ home team. A rank of 0 means the team is unranked.
	HomeRank int `firestore:"home_rank"`

	// AwayRank is the ranking of the _true_ away team. A rank of 0 means the team is unranked.
	AwayRank int `firestore:"away_rank"`

	// HomeFavored tells whether or not the _true_ home team is favored.
	HomeFavored bool `firestore:"home_favored"`

	// GOTW is true if this is a "game of the week."
	GOTW bool `firestore:"gotw"`

	// Superdog is true if this game is a "superdog pick."
	Superdog bool `firestore:"superdog"`

	// Value is the point value of this game.
	Value int `firestore:"value"`

	// NeutralDisagreement is true if the slate disagrees with the _true_ venue of the game.
	NeutralDisagreement bool `firestore:"neutral_disagreement"`

	// HomeDisagreement is true if the slate disagrees with which team is the _true_ home team of the game.
	HomeDisagreement bool `firestore:"home_disagreement"`

	// NoisySpread is the spread against which the pickers are picking this game. A value of zero means a straight pick. Positive values favor `HomeTeam`.
	NoisySpread int `firestore:"noisy_spread"`
}

SlateGame is a game's data as understood by the slate.

func GetSlateGames

func GetSlateGames(ctx context.Context, weekRef *fs.DocumentRef) (sgs []SlateGame, refs []*fs.DocumentRef, err error)

func (SlateGame) String

func (g SlateGame) String() string

String implements the Stringer interface.

type SlateRowBuilder

type SlateRowBuilder interface {
	// BuildSlateRow creates a row of strings for output into a slate spreadsheet.
	BuildSlateRow(ctx context.Context) ([]string, error)
}

type StreakPick

type StreakPick struct {
	// PickedTeams is what the user picked, regardless of the model output.
	// Note that there could be multiple picks per week.
	// An empty array represents a bye pick.
	PickedTeams []*firestore.DocumentRef `firestore:"picks"`

	// StreakPredictions is a reference to the full streak predictions document used to make the pick.
	StreakPredictions *firestore.DocumentRef `firestore:"streak_predictions"`

	// PredictedSpread is the spread of the remaining games in the optimal streak as predicted by the selected model.
	PredictedSpread float64 `firestore:"predicted_spread"`

	// PredictedProbability is the probability of beating the streak.
	PredictedProbability float64 `firestore:"predicted_probability"`

	// Timestamp is the time the picks were written to Firestore.
	Timestamp time.Time `firestore:"timestamp,serverTimestamp"`

	// Picker is a reference to the picker who made the picks.
	Picker *firestore.DocumentRef `firestore:"picker"`
}

StreakPick is a pick for Beat the Streak (BTS).

func GetStreakPick

func GetStreakPick(ctx context.Context, weekRef, pickerRef *firestore.DocumentRef) (pick StreakPick, ref *firestore.DocumentRef, err error)

GetStreakPick gets a picker's BTS pick for a given week.

func GetStreakPicks

func GetStreakPicks(ctx context.Context, weekRef *firestore.DocumentRef) (picks []StreakPick, refs []*firestore.DocumentRef, err error)

GetStreakPicks gets all pickers' BTS picks for a given week.

func (StreakPick) BuildSlateRow

func (sg StreakPick) BuildSlateRow(ctx context.Context) ([]string, error)

BuildSlateRow creates a row of strings for direct output to a slate spreadsheet. TODO: still not printing DDs correctly.

type StreakPrediction

type StreakPrediction struct {

	// CumulativeProbability is the total cumulative probability of streak win for all the picks in `Weeks`.
	CumulativeProbability float64 `firestore:"cumulative_probability"`

	// CumulativeSpread is the total cumulative spreads for all the picks in `Weeks`.
	CumulativeSpread float64 `firestore:"cumulative_spread"`

	// Weeks are the picked streak winners for all future weeks.
	Weeks []StreakWeek `firestore:"weeks"`
}

StreakPrediction is a prediction for a complete streak.

type StreakPredictions

type StreakPredictions struct {
	// Picker is a reference to who is making the pick.
	Picker *firestore.DocumentRef `firestore:"picker"`

	// TeamsRemaining are the teams the picker has remaining to pick in the streak.
	TeamsRemaining []*firestore.DocumentRef `firestore:"remaining"`

	// PickTypesRemaining is an array slice of number of pick types remaining for the user.
	// The index of the array represents the number of picks per week for that type.
	// For instance, the first (index 0) element in the array represents the number of "bye" picks the user has remaining,
	// while the second (index 1) element represents the number of "single" picks remaining,
	// and the third (index 2) represents the number of "double down" weeks remaining.
	PickTypesRemaining []int `firestore:"pick_types_remaining"`

	// Model is a reference to the team points prediction model used to make these predictions.
	Model *firestore.DocumentRef `firestore:"model"`

	// PredictionTracker is a reference to the TPT data used to evaluate the performance of the Sagarin model used to make these predictions.
	PredictionTracker *firestore.DocumentRef `firestore:"prediction_tracker"`

	// CalculationStartTime is when the program that produced the results started.
	CalculationStartTime time.Time `firestore:"calculation_start_time"`

	// CalculationEndTime is when the results were generated and finalized.
	CalculationEndTime time.Time `firestore:"calculation_end_time"`

	// BestPick is a reference to the team to pick this week that the model thinks gives the picker the best chance of beating the streak.
	// Multiple picks are possible per week.
	BestPick []*firestore.DocumentRef `firestore:"best_pick"`

	// Probability is the total probability of beating the streak given optimal selection.
	Probability float64 `firestore:"probability"`

	// Spread is the sum total spread in the picked games given optimal selection.
	Spread float64 `firestore:"spread"`

	// PossiblePicks are the optimal streaks calculated for each possible remaining pick.
	PossiblePicks []StreakPrediction `firestore:"possible_picks"`
}

StreakPredictions records the best predicted streak and the possible streaks for a given picker.

func GetStreakPredictions

func GetStreakPredictions(ctx context.Context, week, picker *firestore.DocumentRef) (StreakPredictions, *firestore.DocumentRef, error)

GetStreakPredictions gets a StreakPredictions for a given picker. Returns an error if the picker does not have a streak prediction for the given week.

type StreakTeamsRemaining

type StreakTeamsRemaining struct {
	// Picker is a reference to the picker.
	Picker *firestore.DocumentRef `firestore:"picker"`

	// TeamsRemaining is a list of references to remaining teams for that picker.
	TeamsRemaining []*firestore.DocumentRef `firestore:"remaining"`

	// PickTypesRemaining is an array slice of number of pick types remaining for the user.
	// The index of the array represents the number of picks per week for that type.
	// For instance, the first (index 0) element in the array represents the number of "bye" picks the user has remaining,
	// while the second (index 1) element represents the number of "single" picks remaining,
	// and the third (index 2) represents the number of "double down" weeks remaining.
	PickTypesRemaining []int `firestore:"pick_types_remaining"`
}

StreakTeamsRemaining represents the remaining teams and pick types per picker

func GetStreakTeamsRemaining

func GetStreakTeamsRemaining(ctx context.Context, season, week, picker *firestore.DocumentRef) (str StreakTeamsRemaining, ref *firestore.DocumentRef, err error)

GetStreakTeamsRemaining looks up the remaining streak teams for a given picker, week combination. If week is nil, returns the remaining streak teams based off the season information.

type StreakWeek

type StreakWeek struct {
	// Pick is a reference to the team to pick this week that the model thinks gives the picker the best chance of beating the streak.
	// Multiple picks are possible per week.
	// An empty array represents a bye pick.
	Pick []*firestore.DocumentRef `firestore:"pick"`

	// Probabilities are the probabilities of each team in `Pick` winning this week.
	Probabilities []float64 `firestore:"probabilities"`

	// Spreads are the predicted spreads of each game in `Pick` (positive favoring the picked team).
	Spreads []float64 `firestore:"spreads"`
}

StreakWeek is a week's worth of streak picks.

type Team

type Team struct {
	// Abbreviation is a short, capitalized abbreviation of the team's name.
	// By convention, it is at most 4 characters long. There is no authoritative list of Name4 names,
	// but traditionally they have been chosen to match the abbreviated names that are used by ESPN.
	// Examples include:
	// - MICH (University of Michigan Wolverines)
	// - OSU (The Ohio State University Buckeyes)
	// - M-OH (Miami University of Ohio RedHawks)
	Abbreviation string `firestore:"abbreviation"`

	// ShortNames are capitalized abbreviations that Luke Heinkel has given to the team.
	// There is no authoritative list of these names, and they are not necessarily consistent over time (hence the array slice).
	// Examples include:
	// - MICH (University of Michigan Wolverines)
	// - OSU (The Ohio State University Buckeyes)
	// - CINCY (University of Cincinnati Bearcats)
	ShortNames []string `firestore:"short_names"`

	// OtherNames are the names that various other documents give to the team.
	// These are collected over time as various sports outlets call the team different official or unofficial names.
	// Examples include:
	// - [Michigan] (University of Michigan Wolverines)
	// - [Ohio St., Ohio State] (The Ohio State University Buckeyes)
	// - [Pitt, Pittsburgh] (University of Pittsburgh Panthers)
	OtherNames []string `firestore:"other_names,omitempty"`

	// School is the unofficial, unabbreviated name of the school used for display purposes.
	// Examples include:
	// - Michigan (University of Michigan Wolverines)
	// - Ohio State (The Ohio State University Buckeyes)
	// - Southern California (University of Southern California Trojans)
	School string `firestore:"school"`

	// Mascot is the official nickname of the team.
	// Examples include:
	// - Wolverines (University of Michigan Wolverines)
	// - Buckeyes (The Ohio State University Buckeyes)
	// - Chanticleers (Coastal Carolina Chanticleers)
	Mascot string `firestore:"mascot"`

	// Colors are the team colors in HTML RGB format ("#RRGGBB").
	Colors []string `firestore:"colors"`

	// Logos are links to logos, typically in size order (smallest first).
	Logos []string `firestore:"logos"`

	// Venue is a reference to a Venue document.
	Venue *firestore.DocumentRef `firestore:"venue"`
}

Team represents an NCAA football team.

func GetTeams

func GetTeams(ctx context.Context, season *firestore.DocumentRef) ([]Team, []*firestore.DocumentRef, error)

GetTeams returns a collection of teams for a given season.

func (Team) String

func (t Team) String() string

type TeamRefsByName

type TeamRefsByName map[string]*firestore.DocumentRef

TeamRefsByName is a type for quick lookups of teams by other name.

func NewTeamRefsByOtherName

func NewTeamRefsByOtherName(teams []Team, refs []*firestore.DocumentRef) TeamRefsByName

func NewTeamRefsByShortName

func NewTeamRefsByShortName(teams []Team, refs []*firestore.DocumentRef) TeamRefsByName

type Venue

type Venue struct {
	Name        string    `firestore:"name"`
	Capacity    int       `firestore:"capacity"`
	Grass       bool      `firestore:"grass"`
	City        string    `firestore:"city"`
	State       string    `firestore:"state"`
	Zip         string    `firestore:"zip"`
	CountryCode string    `firestore:"country_code"`
	LatLon      []float64 `firestore:"latlon"`
	Year        int       `firestore:"year"`
	Dome        bool      `firestore:"dome"`
	Timezone    string    `firestore:"timezone"`
}

func (Venue) String

func (v Venue) String() string

type Week

type Week struct {
	// Number is the week number.
	Number int `firestore:"number"`

	// FirstGameStart is the start time of the first game of the week.
	FirstGameStart time.Time `firestore:"first_game_start"`
}

func GetFirstWeek

func GetFirstWeek(ctx context.Context, season *firestore.DocumentRef) (Week, *firestore.DocumentRef, error)

GetFirstWeek returns the week object and document ref pointer with the earliest value of `first_game_start` in the season.

func GetWeek

func GetWeek(ctx context.Context, season *firestore.DocumentRef, week int) (Week, *firestore.DocumentRef, error)

GetWeek returns the week object and document ref pointer matching the given season document ref and week number. If `week<0`, the week is calculated based on today's date and the week's `first_game_start` field.

func GetWeeks

func GetWeeks(ctx context.Context, season *firestore.DocumentRef) ([]Week, []*firestore.DocumentRef, error)

GetWeeks returns all the week objects and document ref pointers matching the given season document ref.

func (Week) String

func (w Week) String() string

Jump to

Keyboard shortcuts

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