models

package
v0.0.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const CATEGORY_SCHEMA = `` /* 132-byte string literal not displayed */
View Source
const CLUE_SCHEMA = `` /* 366-byte string literal not displayed */
View Source
const GAME_SCHEMA = `` /* 281-byte string literal not displayed */
View Source
const SEASON_SCHEMA = `` /* 139-byte string literal not displayed */
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 GetDBHandle

func GetDBHandle() *sqlx.DB

GetDBHandler returns a new database handle.

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() ([]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 InsertCategory

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

InsertCategory inserts a category into the database.

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:"804092001"`
	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 date, with most recent first.

func GetRandomClue

func GetRandomClue() (*Clue, error)

GetClue returns a single clue from the database.

func (*Clue) String

func (c *Clue) String() string

String implements fmt.Stringer.

type CluesParams

type CluesParams struct {
	GameID     int64
	CategoryID 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() ([]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 (Game) String

func (g Game) String() string

String implements fmt.Stringer for the Game type.

type JeppDB

type JeppDB struct {
	Conn *sqlx.DB
}

JeppDB is a wrapper around sqlx.DB.

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) 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