model

package
v0.0.0-...-ece30a1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call(f string, i ...interface{}) events.APIGatewayProxyResponse

func Delete

func Delete(m Manageable)

func Find

func Find(m Manageable)

func FindUsers

func FindUsers(token string) *[]User

func Save

func Save(s Storable)

func SaveUser

func SaveUser(s *User)

Types

type Challenge

type Challenge struct {
	// Token is a unique 64 character alphanumeric string and identifier of a single Quivlet session.
	Token            string   `json:"token"`
	Index            int      `json:"index"`
	Category         string   `json:"category"`
	Type             string   `json:"type"`
	Difficulty       string   `json:"difficulty"`
	Question         string   `json:"question"`
	CorrectAnswer    string   `json:"correct_answer"`
	IncorrectAnswers []string `json:"incorrect_answers"`
}

func NewChallenge

func NewChallenge(token string) Challenge

func (*Challenge) FindChallenge

func (c *Challenge) FindChallenge()

func (*Challenge) Key

func (c *Challenge) Key() map[string]*dynamodb.AttributeValue

func (*Challenge) SaveChallenge

func (c *Challenge) SaveChallenge()

func (*Challenge) Table

func (c *Challenge) Table() *string

type ChallengeResponse

type ChallengeResponse struct {
	Challenges []Challenge `json:"results"`
}

type Manageable

type Manageable interface {
	Storable
	Key() map[string]*dynamodb.AttributeValue
}

type Session

type Session struct {
	ID string `json:"id"`

	// Token is a unique 64 character alphanumeric string and identifier of a single Quivlet session.
	Token string `json:"token"`

	// Expiry is the Unix (millisecond) value, which defines the deadline for joining this session.
	Expiry int64 `json:"expiry"`
}

Session is an opentdb construct. They are described as unique keys that will help keep track of the questions we have received from said API. The Session Token guarantees that we will not receive the same question twice, until we have exhausted all ≈14,000 questions. Aside: Jeopardy episodes have 94 questions, incl. Daily Doubles and Final Jeopardy.

func FindSession

func FindSession() *Session

func (*Session) DeleteSession

func (s *Session) DeleteSession()

func (*Session) IsEmpty

func (s *Session) IsEmpty() bool

func (*Session) IsExpired

func (s *Session) IsExpired() bool

func (*Session) IsNotEmpty

func (s *Session) IsNotEmpty() bool

func (*Session) IsNotExpired

func (s *Session) IsNotExpired() bool

func (*Session) Key

func (s *Session) Key() map[string]*dynamodb.AttributeValue

func (*Session) NewSession

func (s *Session) NewSession()

NewSession sets the expiry of our future token first to hedge our time bets, retrieves a new token from an API call to the opentdb session token request endpoint, then sets said token on the session.

func (*Session) SaveSession

func (s *Session) SaveSession()

func (*Session) Table

func (s *Session) Table() *string

type Storable

type Storable interface {
	Table() *string
}

type User

type User struct {

	// Token is a unique 64 character alphanumeric string and identifier of a single Quivlet session.
	Token string `json:"token"`

	// ID is the string representation of a 128 bit (16 byte) Universal Unique Identifier as defined in RFC 4122.
	ID string `json:"id"`

	// Name is a self defined or randomly generated username for friendly statistic reporting.
	Name string `json:"name"`

	// Result is a slice of int64's where each value represents a correctly answered challenge in a certain time period.
	Result []int64 `json:"result"`

	// Eliminated is used to flag a user that answered a challenge incorrectly and no longer part of the contest.
	Eliminated bool `json:"eliminated"`

	Save bool
}

User is the identity associated with a Quivlet contestant.

func (*User) SaveUser

func (u *User) SaveUser()

func (*User) Table

func (u *User) Table() *string

Jump to

Keyboard shortcuts

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