database

package
v0.0.0-...-c5fd561 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindMostSimilarPlayerIDs

func FindMostSimilarPlayerIDs(similarToPlayerID, limit int, playerZScores []model.StandardizedPlayerStats) []int

func GetDatabase

func GetDatabase(league string) (*sqlx.DB, error)

func Getprizepicks

func Getprizepicks(nbaClient BasketballRepository)

func ParsePrizePickProposition

func ParsePrizePickProposition(db BasketballRepository, schedule model.Schedule, prop model.PrizePicksData, itemIDToNameMap map[string]string) (proposition *model.DBProposition, game *model.PlayerGame, err error)

func SQLDateBefore

func SQLDateBefore(date time.Time) string

func SimilarPlayerFilters

func SimilarPlayerFilters(season model.SeasonOption, endDate string, playerIDs []int) []*model.PlayerFilter

Types

type BasketballRepository

type BasketballRepository interface {
	GetLeague() string
	CountQueries() int
	SetQueries(int)
	AddQuery()
	GetPlayers(ctx context.Context, withGames bool, playerFilters ...*model.PlayerFilter) ([]*model.Player, error)
	GetPropositions(ctx context.Context, propositionFilter *model.PropositionFilter) ([]*model.Proposition, error)
	SavePropositions(ctx context.Context, propositions []*model.Proposition) (int, error)
	SaveDBPropositions(ctx context.Context, propositions []*model.DBProposition) (int, error)
	SaveUpcomingGames(ctx context.Context, games []*model.PlayerGame) (int, error)
	// GetTeamsByID(ctx context.Context, teamIDs []int) ([]*model.Team, error)
	// GetTeamsByAbr(ctx context.Context, teamAbrs []string) ([]*model.Team, error)
	GetTeams(ctx context.Context, withGames bool, teamFilters ...*model.TeamFilter) ([]*model.Team, error)
	GetSimilarPlayers(ctx context.Context, similarToPlayerID int, input *model.SimilarPlayerInput, endDate *time.Time) ([]*model.Player, error)
	GetSimilarTeams(ctx context.Context, similarToTeamID int, input *model.SimilarTeamInput, endDate string) ([]*model.Team, error)
	GetPropositionsByPlayerGame(ctx context.Context, game model.PlayerGame) ([]*model.Proposition, error)
	GetPlayerGames(ctx context.Context, inputs ...model.GameFilter) ([]*model.PlayerGame, error)
	GetStandardizedPlayerStats(ctx context.Context, similarPlayerQuery model.SimilarPlayerQuery, toPlayerIDs ...int) ([]model.StandardizedPlayerStats, error)
}

type MongoClient

type MongoClient struct {
	Name string
	*mongo.Database

	Queries          int
	Client           *mongo.Client
	PlayerSimilarity model.PlayerSnapshots
	TeamSimilarity   model.TeamSnapshots
	PlayerCache      map[string][]*model.Player
	TeamCache        map[string][]*model.Team
	// contains filtered or unexported fields
}

func ConnectDB

func ConnectDB(ctx context.Context, db string) (*MongoClient, error)

func (*MongoClient) GetLeague

func (c *MongoClient) GetLeague() string

func (*MongoClient) GetPlayerGames

func (c *MongoClient) GetPlayerGames(ctx context.Context, input *model.GameFilter) ([]*model.PlayerGame, error)

func (*MongoClient) GetPlayers

func (c *MongoClient) GetPlayers(ctx context.Context, withGames bool, inputs ...*model.PlayerFilter) ([]*model.Player, error)

func (*MongoClient) GetPropositions

func (c *MongoClient) GetPropositions(ctx context.Context, input *model.PropositionFilter) ([]*model.Proposition, error)

func (*MongoClient) GetPropositionsByPlayerGame

func (c *MongoClient) GetPropositionsByPlayerGame(ctx context.Context, game model.PlayerGame) ([]*model.Proposition, error)

func (*MongoClient) GetSimilarPlayers

func (c *MongoClient) GetSimilarPlayers(ctx context.Context, similarToPlayerID int, input *model.SimilarPlayerInput, endDate string) ([]*model.Player, error)

func (*MongoClient) GetSimilarTeams

func (c *MongoClient) GetSimilarTeams(ctx context.Context, similarToTeamID int, input *model.SimilarTeamInput, endDate string) ([]*model.Team, error)

func (*MongoClient) GetTeams

func (c *MongoClient) GetTeams(ctx context.Context, withGames bool, inputs *[]*model.TeamFilter) ([]*model.Team, error)

func (*MongoClient) SavePropositions

func (c *MongoClient) SavePropositions(ctx context.Context, propositions []*model.DBProposition) (int, error)

func (*MongoClient) SaveUpcomingGames

func (c *MongoClient) SaveUpcomingGames(ctx context.Context, games []*model.PlayerGame) (int, error)

type SQLClient

type SQLClient struct {
	League  string
	Queries int
	*sqlx.DB
}

func NewSQLClient

func NewSQLClient(league string) (*SQLClient, error)

func (*SQLClient) AddQuery

func (c *SQLClient) AddQuery()

func (*SQLClient) CountQueries

func (c *SQLClient) CountQueries() int

func (*SQLClient) GetLeague

func (c *SQLClient) GetLeague() string

func (*SQLClient) GetPlayerGames

func (c *SQLClient) GetPlayerGames(ctx context.Context, inputs ...model.GameFilter) (games []*model.PlayerGame, err error)

func (*SQLClient) GetPlayers

func (c *SQLClient) GetPlayers(ctx context.Context, withGames bool, playerFilters ...*model.PlayerFilter) ([]*model.Player, error)

func (*SQLClient) GetPropositions

func (c *SQLClient) GetPropositions(ctx context.Context, propositionFilter *model.PropositionFilter) ([]*model.Proposition, error)

func (*SQLClient) GetPropositionsByPlayerGame

func (c *SQLClient) GetPropositionsByPlayerGame(ctx context.Context, game model.PlayerGame) ([]*model.Proposition, error)

func (*SQLClient) GetSimilarPlayers

func (c *SQLClient) GetSimilarPlayers(ctx context.Context, similarToPlayerID int, input *model.SimilarPlayerInput, endDate *time.Time) ([]*model.Player, error)

func (*SQLClient) GetSimilarTeams

func (c *SQLClient) GetSimilarTeams(ctx context.Context, similarToTeamID int, input *model.SimilarTeamInput, endDate string) ([]*model.Team, error)

func (*SQLClient) GetStandardizedPlayerStats

func (c *SQLClient) GetStandardizedPlayerStats(ctx context.Context, similarPlayerQuery model.SimilarPlayerQuery, toPlayerIDs ...int) ([]model.StandardizedPlayerStats, error)

func (*SQLClient) GetTeams

func (c *SQLClient) GetTeams(ctx context.Context, withGames bool, teamFilters ...*model.TeamFilter) ([]*model.Team, error)

func (*SQLClient) SaveDBPropositions

func (c *SQLClient) SaveDBPropositions(ctx context.Context, propositions []*model.DBProposition) (int, error)

func (*SQLClient) SavePropositions

func (c *SQLClient) SavePropositions(ctx context.Context, propositions []*model.Proposition) (int, error)

func (*SQLClient) SaveUpcomingGames

func (c *SQLClient) SaveUpcomingGames(ctx context.Context, games []*model.PlayerGame) (int, error)

func (*SQLClient) SetQueries

func (c *SQLClient) SetQueries(q int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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