models

package
v0.2.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: 8 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

func CountClues added in v0.0.4

func CountClues() (int64, error)

CountClues returns the number of clues in the database.

func GetCategoryClueCount

func GetCategoryClueCount(categoryID int64) (int64, error)

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

func GetCategoryGameCount

func GetCategoryGameCount(categoryID int64) (int64, error)

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

func InsertClue

func InsertClue(c *Clue) error

InsertClue inserts a clue into the database.

func InsertGame

func InsertGame(g *Game) error

InsertGame inserts a game into the database.

func InsertSeason

func InsertSeason(s *Season) error

InsertSeason inserts a season into the database.

func UpdateCategory

func UpdateCategory(c *Category) error

UpdateCategory updates a category in the database.

func UpdateClue

func UpdateClue(c *Clue) error

UpdateClue updates a category in the database.

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 GetCategories

func GetCategories(limit int64) ([]Category, error)

GetCategories returns all categories in the database.

func GetCategoriesForGame

func GetCategoriesForGame(gameID int64) ([]Category, error)

GetCategoriesForGame returns all categories for a given game.

func GetCategory

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

GetCategory returns the category with the given ID.

func GetCategoryByName

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

func GetRandomCategory

func GetRandomCategory() (*Category, error)

GetRandomCategory returns a single category from the database.

func GetRandomCategoryMany added in v0.0.9

func GetRandomCategoryMany(limit int64) ([]Category, error)

GetRandomCategoryMany returns `limit` random categories from the database.

func InsertCategory

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

InsertCategory inserts a category into 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 GetClue

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

GetClue returns a single clue from the database.

func GetClues

func GetClues(params CluesParams) ([]Clue, error)

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

func GetRandomClue

func GetRandomClue() (*Clue, error)

GetClue returns a single clue from the database.

func GetRandomClueMany added in v0.0.9

func GetRandomClueMany(limit int64) ([]Clue, error)

GetRandomClueMany returns `limit` random clues from 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 GetGame

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

GetGame returns a single game from the database.

func GetGames

func 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 GetGamesBySeason

func GetGamesBySeason(seasonID int64) ([]Game, error)

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

func GetRandomGame

func GetRandomGame() (*Game, error)

GetRandomGame returns a single game from the database.

func GetRandomGameMany added in v0.0.9

func GetRandomGameMany(limit int64) ([]Game, error)

GetRandomGameMany returns `limit` random games from the database.

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() *JeppDB

func NewTestJeppDB added in v0.2.0

func NewTestJeppDB() *JeppDB

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 GetSeasons

func 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 (*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