golfer

package
v0.0.0-...-a1630c6 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FollowLimit        = 10
	FollowLimitSponsor = 24
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FailingSolutions

type FailingSolutions []struct{ Hole, Lang string }

func (*FailingSolutions) Scan

func (f *FailingSolutions) Scan(src any) error

type Golfer

type Golfer struct {
	Admin, ShowCountry, Sponsor   bool
	BytesPoints, CharsPoints, ID  int
	Cheevos, Holes                pq.StringArray
	Country                       config.NullCountry
	Delete                        null.Time
	FailingSolutions              FailingSolutions
	Following                     pq.Int64Array
	Keymap, Name, Referrer, Theme string
	Pronouns, TimeZone            null.String
	Settings                      Settings
}

Golfer is the info of a logged in golfer we need on every request.

func Get

func Get(db *sqlx.DB, sessionID uuid.UUID) *Golfer

Get a Golfer given a session ID, updates the session's last used time.

func (*Golfer) Earn

func (g *Golfer) Earn(db *sqlx.DB, cheevoID string) (earned *config.Cheevo)

Earn the given cheevo, no-op if already earned.

func (*Golfer) Earned

func (g *Golfer) Earned(cheevoID string) bool

Earned returns whether the golfer has that cheevo.

func (*Golfer) FollowLimit

func (g *Golfer) FollowLimit() int

FollowLimit returns the max number of golfers this golfer can follow.

func (*Golfer) IsFollowing

func (g *Golfer) IsFollowing(userID int) bool

IsFollowing returns whether the golfer is following that golfer. FIXME Ideally we'd scan into a []int not a []int64 but pq won't.

func (*Golfer) Location

func (g *Golfer) Location() (loc *time.Location)

func (*Golfer) SaveSettings

func (g *Golfer) SaveSettings(db *sqlx.DB)

SaveSettings saves golfer.Settings back to the DB.

func (*Golfer) Solved

func (g *Golfer) Solved(holeID string) bool

Solved returns whether the golfer has solved that hole. Counts failing too.

type GolferInfo

type GolferInfo struct {
	Golfer

	// Count of medals
	Diamond, Gold, Silver, Bronze int

	// Count of cheevos/holes/langs done
	Holes, Langs int

	// Count of cheevos/holes/langs available
	CheevosTotal, HolesTotal, LangsTotal int

	// Slice of golfers referred
	Referrals pq.StringArray

	// Start date
	Started time.Time
}

GolferInfo is populated when looking at a /golfers/xxx route.

func GetInfo

func GetInfo(db *sqlx.DB, name string) *GolferInfo

type RankUpdate

type RankUpdate struct {
	Scoring            string           `json:"scoring"`
	From               RankUpdateFromTo `json:"from"`
	To                 RankUpdateFromTo `json:"to"`
	OldBestGolferCount null.Int         `json:"oldBestGolferCount"` // Number of golfers that previously held the gold medal (except current golfer).
	OldBestGolferID    null.Int         `json:"oldBestGolferID"`    // ID of the golfer that previously held the diamond (except current golfer).
	OldBestStrokes     null.Int         `json:"oldBestStrokes"`     // Number of strokes for previous diamond (including current golfer).
	OldBestSubmitted   null.Time        `json:"oldBestSubmitted"`   // Timestamp for previous diamond (including current golfer).
}

type RankUpdateFromTo

type RankUpdateFromTo struct {
	Joint   null.Bool `json:"joint"`
	Rank    null.Int  `json:"rank"`
	Strokes null.Int  `json:"strokes"`
}

FIXME I'm not sure these RankUpdate structs belong here.

type Settings

type Settings map[string]map[string]any

Settings is page → setting → value.

func (*Settings) Scan

func (s *Settings) Scan(v any) error

func (Settings) Value

func (s Settings) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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