stats

package
v0.0.0-...-4126366 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	*sqlx.DB
}

Database represents a database.

func Connect

func Connect(addr string) (*Database, error)

func (*Database) WithContext

func (db *Database) WithContext(ctx context.Context) ReadView

type Map

type Map struct {
	Name     string `db:"name"`
	Kills    int64  `db:"kills"`
	Points   int64  `db:"points"`
	Playtime int64  `db:"playtime"` // minutes
}

func (Map) ConvertPlaytime

func (m Map) ConvertPlaytime() time.Duration

type Player

type Player struct {
	Index             int     `db:"ix" rfsql:"-"`
	SteamID           SteamID `db:"steamid"`
	Name              string  `db:"name"`
	Kills             int64   `db:"kills"`
	Points            int64   `db:"points"`
	Playtime          int64   `db:"playtime"`
	MeleeKills        int64   `db:"melee_kills"`
	Headshots         int64   `db:"headshots"`
	AwardFriendlyfire int64   `db:"award_friendlyfire"`
	AwardFincap       int64   `db:"award_fincap"`
}

Player contains some statistics of each player.

func (Player) ConvertPlaytime

func (p Player) ConvertPlaytime() time.Duration

func (Player) URL

func (p Player) URL() string

URL returns the link to the player's profile.

type PlayerResults

type PlayerResults struct {
	Players []Player
	HasMore bool
}

type ReadView

type ReadView struct {
	*Database
	// contains filtered or unexported fields
}

func (*ReadView) Leaderboard

func (rv *ReadView) Leaderboard(search, sort string, count, page int) (PlayerResults, error)

Leaderboard searches the leaderboard for players. The page count is zero-indexed.

func (*ReadView) Statistics

func (rv *ReadView) Statistics() (*Statistics, error)

func (*ReadView) TopMaps

func (rv *ReadView) TopMaps(limit int) (maps []Map, err error)

func (*ReadView) TopPlayers

func (rv *ReadView) TopPlayers(sort string, count int) ([]Player, error)

TopPlayers returns the top players from the leaderboard. It does not paginate.

type Statistics

type Statistics struct {
	PlayersServed  int64 `db:"players_served"`
	TotalKills     int64 `db:"total_kills"`
	TotalPoints    int64 `db:"total_points"`
	TotalPlaytime  int64 `db:"total_playtime"`
	TotalHeadshots int64 `db:"total_headshots"`
}

Statistics contains general statistics.

func (Statistics) ConvertTotalPlaytime

func (s Statistics) ConvertTotalPlaytime() time.Duration

type SteamID

type SteamID string

func (SteamID) ToSteamID64

func (id SteamID) ToSteamID64() int64

ToSteamID64 converts the steam ID to its ID64 variant.

func (SteamID) URL

func (id SteamID) URL() string

URL returns the link to the user's profile.

Jump to

Keyboard shortcuts

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