quickdraw

package
v0.0.0-...-146fb43 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// LowPick is the lowest pick number available
	LowPick = 1
	// HighPick is the highest pick number available
	HighPick = 80
)

Variables

This section is empty.

Functions

func GetDb

func GetDb(connStr string) *sql.DB

GetDb opens the database w/ postgres driver

func GetTotalRowsCount

func GetTotalRowsCount(db *sql.DB) (int, error)

GetTotalRowsCount gets the total number of records in the database for pagination purposes

func GetWinningNumbersFor

func GetWinningNumbersFor(viewName string, db *sql.DB) (map[int]int, error)

GetWinningNumbersFor retrieves a view in the database relating to the past winning numbers based on the viewname

func ImportLatest

func ImportLatest(db *sql.DB) error

ImportLatest imports the latest entries from the API

func ImportPicks

func ImportPicks(db *sql.DB, csvFile string) error

ImportPicks imports picks from a CSV

func RefreshViews

func RefreshViews(db *sql.DB) error

RefreshViews will refresh the materialized views

func ScrapeLiveDraws

func ScrapeLiveDraws(db *sql.DB) error

ScrapeLiveDraws scrapes the live website for new draw data and inserts it into db

Types

type API

type API struct {
	Db          *sql.DB
	Host        string
	Port        int
	AllowedURLs []string
}

API represents the API singleton

func (*API) Serve

func (a *API) Serve()

Serve starts the API server

type Draw

type Draw struct {
	DrawDate       time.Time `json:"draw_date"`
	DrawNumber     int       `json:"draw_number"`
	DrawTime       string    `json:"draw_time"`
	WinningNumbers []int64   `json:"winning_numbers"`
	Extra          int       `json:"extra_multiplier"`
}

Draw represents a quickdraw entry

func (Draw) CheckAndInsert

func (d Draw) CheckAndInsert(db *sql.DB) error

CheckAndInsert checks if a draw exists and if it doesn't, inserts it into the database

func (Draw) Insert

func (d Draw) Insert(db *sql.DB) error

Insert inserts a draw into the database

func (*Draw) UnmarshalJSON

func (d *Draw) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals custom into Draw struct

func (Draw) WinningNumbersString

func (d Draw) WinningNumbersString() string

WinningNumbersString converts the winning numbers array to a string value

type Draws

type Draws []*Draw

Draws is a collection of Draw

func GetDraws

func GetDraws(db *sql.DB, pageNum int, pageSize int, orderBy string, sortDir string) (Draws, error)

GetDraws queries all draws based on the arguments provided

type TableResponse

type TableResponse struct {
	Draws    []*Draw `json:"draws"`
	Total    int     `json:"total"`
	Page     int     `json:"page"`
	PageSize int     `json:"page_size"`
}

Jump to

Keyboard shortcuts

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