db

package
v0.0.0-...-26761ab Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPlayerExistsByPhoneNumber

func CheckPlayerExistsByPhoneNumber(tx *sql.Tx, eventID *string, phoneNumber *string) (
	bool, error)

CheckPlayerExistsByPhoneNumber returns true if the `eventID` + `phoneNumber` combination is valid.

func CreatePlayer

func CreatePlayer(tx *sql.Tx, eventID *string, name *string, league pg.League, phoneNumber *string,
	randCode uint32) error

CreatePlayer inserts a new player into the database in an unconfirmed state.

func GenerateAuthToken

func GenerateAuthToken(tx *sql.Tx, eventID *string, phoneNumber *string) error

GenerateAuthToken un-sets a user's auth code and generates a fresh auth token.

func GetEventID

func GetEventID(tx *sql.Tx, eventKey *string) (string, error)

GetEventID accepts an `eventKey` and returns a corresponding event ID to bypass joins in later queries. An empty string is returned if the event key does not exist.

func GetPlayerAuthInfo

func GetPlayerAuthInfo(tx *sql.Tx, eventID *string, phoneNumber *string) (authToken string, playerID string,
	role pg.PlayerRole, err error)

GetPlayerAuthInfo returns a user's auth token, ID and role.

func GetPlayerName

func GetPlayerName(tx *sql.Tx, playerID *string) (string, error)

GetPlayerName returns the display name for a given `playerID`.

func GetPlayerScores

func GetPlayerScores(tx *sql.Tx, eventID *string, playerID *string) ([]*pg.Score, error)

GetPlayerScores returns all scores for a given player and event.

func GetScheduleForEvent

func GetScheduleForEvent(tx *sql.Tx, eventID *string) (pg.VenueList, error)

GetScheduleForEvent returns the venue list for an event.

func GetScoreboardBestOf5

func GetScoreboardBestOf5(tx *sql.Tx, eventID *string) ([]*pg.Score, error)

GetScoreboardBestOf5 returns scores for all players that are eligible for the "Best of 5" category (but not eligible for "Best of 9").

func GetScoreboardBestOf9

func GetScoreboardBestOf9(tx *sql.Tx, eventID *string) ([]*pg.Score, error)

GetScoreboardBestOf9 returns scores for all players that are eligible for the "Best of 9" category.

func GetScoreboardIncomplete

func GetScoreboardIncomplete(tx *sql.Tx, eventID *string) ([]*pg.Score, error)

GetScoreboardIncomplete returns scores for all players that aren't eligible for either the "Best of 9" or "Best of 5" categories.

func PlayerRoleFromDBFormat

func PlayerRoleFromDBFormat(roleRaw []uint8) pg.PlayerRole

func SetAuthCode

func SetAuthCode(tx *sql.Tx, eventID *string, phoneNumber *string, authCode uint32) error

SetAuthCode updates the auth code (and expiration time) for a player's auth code.

func ValidateAuthCode

func ValidateAuthCode(tx *sql.Tx, eventID *string, phoneNumber *string, authCode uint32) (bool, error)

ValidateAuthCode confirms the validity (equality and expiration window) of a provided `authCode` for a given user.

func ValidateAuthToken

func ValidateAuthToken(tx *sql.Tx, authToken *string) (eventID string, playerID string, role pg.PlayerRole, err error)

ValidateAuthToken returns the corresponding event ID and player ID for a valid `authToken`. In the event of an invalid `authToken`, an empty string will be returned as both IDs.

Types

This section is empty.

Jump to

Keyboard shortcuts

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