models

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const TIME_FORMAT = "Monday, January 2, 2006"

TIME_FORMAT is the format used for friendly date strings. This is the format used by j-archive.

Variables

View Source
var RoundMap = map[string]int{
	"J":  int(Jeopardy),
	"DJ": int(DoubleJeopardy),
	"FJ": int(FinalJeopardy),
	"TB": int(FinalJeopardy),
}

Functions

This section is empty.

Types

type Category

type Category struct {
	CategoryID int64  `db:"category_id" json:"categoryId" example:"765"`
	Name       string `db:"name" json:"name" example:"State Capitals"`
}

Category represents a jeopardy category in the database.

func (*Category) Dump added in v0.0.14

func (c *Category) Dump() []string

type Clue

type Clue struct {
	ClueID     int64  `db:"clue_id" json:"clueId" example:"804002032"`
	GameID     int64  `db:"game_id" json:"gameId" example:"8040"`
	CategoryID int64  `db:"category_id" json:"categoryId" example:"3462"`
	Question   string `db:"question" json:"question" example:"This is the question."`
	Answer     string `db:"answer" json:"answer" example:"This is the answer."`
}

Clue represents a jeopardy clue in the database.

func (*Clue) Dump added in v0.0.14

func (c *Clue) Dump() []string

func (*Clue) String

func (c *Clue) String() string

String implements the Stringer interface for the Clue type.

type CluesParams

type CluesParams struct {
	GameID     int64
	CategoryID int64
	Page       int64
	Limit      int64
}

type Game

type Game struct {
	GameID    int64     `db:"game_id" json:"gameId" example:"8040"`
	SeasonID  int64     `db:"season_id" json:"seasonId" example:"38"`
	ShowNum   int64     `db:"show_num" json:"showNum" example:"4532"`
	GameDate  time.Time `db:"game_date" json:"gameDate" example:"2019-01-01"`
	TapedDate time.Time `db:"taped_date" json:"tapedDate" example:"2019-01-01"`
}

Game represents a single game of Jeopardy.

func (*Game) Dump added in v0.0.14

func (g *Game) Dump() []string

func (Game) String

func (g Game) String() string

String implements fmt.Stringer for the Game type.

type JeppDB

type JeppDB struct {
	*sqlx.DB
}

func NewJeppDB added in v0.1.0

func NewJeppDB(dbfile string) *JeppDB

func (*JeppDB) CountClues added in v0.1.0

func (db *JeppDB) CountClues() (int64, error)

CountClues returns the number of clues in the database.

func (*JeppDB) GetCategories added in v0.1.0

func (db *JeppDB) GetCategories(limit int64) ([]Category, error)

GetCategories returns all categories in the database.

func (*JeppDB) GetCategoriesForGame added in v0.1.0

func (db *JeppDB) GetCategoriesForGame(gameID int64) ([]Category, error)

GetCategoriesForGame returns all categories for a given game.

func (*JeppDB) GetCategory added in v0.1.0

func (db *JeppDB) GetCategory(categoryID int64) (*Category, error)

GetCategory returns the category with the given ID.

func (*JeppDB) GetCategoryByName added in v0.1.0

func (db *JeppDB) GetCategoryByName(categoryName string) (*Category, error)

func (*JeppDB) GetCategoryClueCount added in v0.1.0

func (db *JeppDB) GetCategoryClueCount(categoryID int64) (int64, error)

GetCategoryClueCount returns the number of clues a category has appeared in.

func (*JeppDB) GetCategoryGameCount added in v0.1.0

func (db *JeppDB) GetCategoryGameCount(categoryID int64) (int64, error)

GetCategoryGameCount returns the number of games a category has appeared in.

func (*JeppDB) GetClue added in v0.1.0

func (db *JeppDB) GetClue(clueID int64) (*Clue, error)

GetClue returns a single clue from the database.

func (*JeppDB) GetClues added in v0.1.0

func (db *JeppDB) GetClues(params CluesParams) ([]Clue, error)

ListClues returns a list of clues in the database, defaults to returning values ordered by game id descending.

func (*JeppDB) GetGame added in v0.1.0

func (db *JeppDB) GetGame(gameID int64) (*Game, error)

GetGame returns a single game from the database.

func (*JeppDB) GetGames added in v0.1.0

func (db *JeppDB) GetGames(limit int64) ([]Game, error)

GetGames returns a list of games in the database, defaults to returning values ordered by game date, with most recent first, limited to 100 results.

TODO: have this take a "lastClueID" arg or something for dumb pagination.

func (*JeppDB) GetGamesBySeason added in v0.1.0

func (db *JeppDB) GetGamesBySeason(seasonID int64) ([]Game, error)

GetGamesBySeason returns a list of games in the database for a given season.

func (*JeppDB) GetRandomCategory added in v0.1.0

func (db *JeppDB) GetRandomCategory() (*Category, error)

GetRandomCategory returns a single category from the database.

func (*JeppDB) GetRandomCategoryMany added in v0.1.0

func (db *JeppDB) GetRandomCategoryMany(limit int64) ([]Category, error)

GetRandomCategoryMany returns `limit` random categories from the database.

func (*JeppDB) GetRandomClue added in v0.1.0

func (db *JeppDB) GetRandomClue() (*Clue, error)

GetClue returns a single clue from the database.

func (*JeppDB) GetRandomClueMany added in v0.1.0

func (db *JeppDB) GetRandomClueMany(limit int64) ([]Clue, error)

GetRandomClueMany returns `limit` random clues from the database.

func (*JeppDB) GetRandomGame added in v0.1.0

func (db *JeppDB) GetRandomGame() (*Game, error)

GetRandomGame returns a single game from the database.

func (*JeppDB) GetRandomGameMany added in v0.1.0

func (db *JeppDB) GetRandomGameMany(limit int64) ([]Game, error)

GetRandomGameMany returns `limit` random games from the database.

func (*JeppDB) GetSeasons added in v0.1.0

func (db *JeppDB) GetSeasons() ([]Season, error)

GetSeasons returns a list of seasons in the database, defaults to returning values ordered by season id, with most recent first.

func (*JeppDB) InsertCategory added in v0.1.0

func (db *JeppDB) InsertCategory(name string) (*Category, error)

InsertCategory inserts a category into the database.

func (*JeppDB) InsertClue added in v0.1.0

func (db *JeppDB) InsertClue(c *Clue) error

InsertClue inserts a clue into the database.

func (*JeppDB) InsertGame added in v0.1.0

func (db *JeppDB) InsertGame(g *Game) error

InsertGame inserts a game into the database.

func (*JeppDB) InsertSeason added in v0.1.0

func (db *JeppDB) InsertSeason(s *Season) error

InsertSeason inserts a season into the database.

func (*JeppDB) UpdateCategory added in v0.1.0

func (db *JeppDB) UpdateCategory(c *Category) error

UpdateCategory updates a category in the database.

func (*JeppDB) UpdateClue added in v0.1.0

func (db *JeppDB) UpdateClue(c *Clue) error

UpdateClue updates a category in the database.

type Round

type Round int // 0 = Jeopardy, 1 = Double Jeopardy, 2 = Final Jeopardy

TODO: this is silly, should fix it

const (
	Jeopardy Round = iota + 1
	DoubleJeopardy
	FinalJeopardy
)

type Season

type Season struct {
	SeasonID  int64     `db:"season_id" json:"seasonId" example:"38"`
	StartDate time.Time `db:"start_date" json:"startDate" example:"2001-09-03T00:00:00Z"`
	EndDate   time.Time `db:"end_date" json:"endDate" example:"2002-07-26T00:00:00Z"`
}

func (*Season) Dump added in v0.0.14

func (s *Season) Dump() []string

func (Season) String

func (s Season) String() string

String implements fmt.Stringer for the Season type.

Jump to

Keyboard shortcuts

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