nfl-pickem: github.com/ameske/nfl-pickem Index | Files | Directories

package nflpickem

import "github.com/ameske/nfl-pickem"

Index

Package Files

date.go game.go nflpickem.go pick.go result.go user.go

Variables

var (
    ErrGameLocked       = errors.New("game has already started - pick locked")
    ErrUnknownSelection = errors.New("selection does not match a game in the given pick set")
)

type CredentialChecker Uses

type CredentialChecker interface {
    CheckCredentials(username string, password string) (User, error)
}

type DataSummarizer Uses

type DataSummarizer interface {
    Years() ([]int, error)
}

type DateAdder Uses

type DateAdder interface {
    AddYear(year int, start int) error
    AddWeek(year int, week int) error
}

DateAdder is the interface implemented by types who can add years and weeks to a data source

type Game Uses

type Game struct {
    Year      int       `json:"year"`
    Week      int       `json:"week"`
    Date      time.Time `json:"date"`
    Home      Team      `json:"home"`
    Away      Team      `json:"away"`
    HomeScore int       `json:"homeScore"`
    AwayScore int       `json:"awayScore"`
}

Game represents an NFL contest.

func (Game) Equal Uses

func (g Game) Equal(other Game) bool

type GameAdder Uses

type GameAdder interface {
    AddGame(date time.Time, homeTeam string, awayTeam string) error
}

GameAdder is the interface implemented by a type that can add games to a data source

type GamesRetriever Uses

type GamesRetriever interface {
    WeekGames(year int, week int) ([]Game, error)
    CumulativeGames(year int, week int) ([]Game, error)
}

GamesRetriever is the interface implemented by a type that can retrieve NFL game information.

type Notifier Uses

type Notifier interface {
    Notify(to string, week int, picks []Pick) error
}

type PasswordUpdater Uses

type PasswordUpdater interface {
    UpdatePassword(username string, oldPassword string, newPassword string) error
}

type Pick Uses

type Pick struct {
    Game      Game `json:"game"`
    User      User `json:"user"`
    Selection Team `json:"selection"`
    Points    int  `json:"points"`
}

A Pick represents a user's selection for a given game.

The Pick can stand on its own since it contains embedded game information

func (Pick) Equal Uses

func (p Pick) Equal(other Pick) bool

type PickCreater Uses

type PickCreater interface {
    CreatePicks(username string, year int, week int) error
}

PickCreater is the interface implemented by a type that can add picks to a data source.

type PickFilterFunc Uses

type PickFilterFunc func(p Pick) bool

type PickResult Uses

type PickResult struct {
    User      User `json:"user"`
    Selection Team `json:"selection"`
    Points    int  `json:"points"`
}

PickResult contains just the pick information for a given game and user.

A PickResult is not very useful on its own, and is always returned as part of a Result so that the client is able to associate it with a game.

type PickRetriever Uses

type PickRetriever interface {
    Picks(year int, week int) (PickSet, error)
    UserPicks(username string, year int, week int) (PickSet, error)
}

PickRetriever is the interface implemented by types that can retrieve Pick information

type PickSet Uses

type PickSet []Pick

A PickSet represents the set of all picks for a user for a given Week

func (PickSet) Filter Uses

func (picks PickSet) Filter(f PickFilterFunc) PickSet

func (PickSet) IsLegal Uses

func (picks PickSet) IsLegal() bool

IsLegal returns whether or not the current set of picks is considered legal.

A PickSet is legal if it doesn't contain too many "special" point values, and contains picks for the same year, week, and user.

func (PickSet) Merge Uses

func (picks PickSet) Merge(other PickSet) error

Merge compares the original PickSet to the new PickSet, updating any picks that differ.

type Picker Uses

type Picker interface {
    MakePicks(PickSet) error
}

Picker is the interface implemented by a type that can make/update picks

type Result Uses

type Result struct {
    Game  Game         `json:"game"`
    Picks []PickResult `json:"picks"`
}

A Result consists of a game, and all of the picks made by users for that game.

type ResultFetcher Uses

type ResultFetcher interface {
    Results(t time.Time, year int, week int) ([]Result, error)
}

ResultFetcher is the interface implemented by types that can fetch results for a given year, and week of a season.

type Service Uses

type Service interface {
    Weeker
    GamesRetriever
    PasswordUpdater
    Picker
    PickRetriever
    ResultFetcher
    WeekTotalFetcher
    CredentialChecker
    DataSummarizer
    UserAdder
    GameAdder
    DateAdder
    PickCreater
}

Service is the interface implemented by types that can provide all the various services needed by the NFL Pickem Pool

type Team Uses

type Team struct {
    City     string `json:"city"`
    Nickname string `json:"nickname"`
}

Team represents an NFL team

func (Team) Equal Uses

func (t Team) Equal(other Team) bool

type Updater Uses

type Updater interface {
    Weeker
    UpdateGame(week int, year int, homeTeam string, homeScore int, awayScore int) error
}

type User Uses

type User struct {
    FirstName string `json:"firstName"`
    LastName  string `json:"lastName"`
    Email     string `json:"email"`
    Admin     bool   `json:"admin"`
}

User represents a user of the NFL Pickem' Pool

func (User) Equal Uses

func (u User) Equal(other User) bool

type UserAdder Uses

type UserAdder interface {
    AddUser(first string, last string, email string, password string, admin bool) error
}

type Week Uses

type Week struct {
    Year int `json:"year"`
    Week int `json:"week"`
}

Week represents a unique week of the NFL Pickem' Pool

type WeekTotal Uses

type WeekTotal struct {
    User  User `json:"user"`
    Year  int  `json:"year"`
    Week  int  `json:"week"`
    Total int  `json:"total"`
}

WeekTotal is the aggregation of all correct picks for a user.

type WeekTotalFetcher Uses

type WeekTotalFetcher interface {
    WeekTotals(year int, week int) ([]WeekTotal, error)
    CumulativeWeekTotals(year int, wee int) ([]WeekTotal, error)
}

WeekTotalFetcher is the interface implemented by types that can retrieve the aggregated results for a given week.

type Weeker Uses

type Weeker interface {
    CurrentWeek(t time.Time) (w Week, err error)
}

Weeker is the interface implemented by types who can retrieve the current week of the NFL season given a point in time.

Directories

PathSynopsis
http
sqlite3

Package nflpickem imports 2 packages (graph) and is imported by 2 packages. Updated 2017-10-29. Refresh now. Tools for package owners.