parkrun

package
v0.0.0-...-ada430c Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SEX_UNKNOWN = iota
	SEX_FEMALE
	SEX_MALE
)

Variables

View Source
var MaxFileAge time.Duration = 24 * time.Hour

Functions

func CachePath

func CachePath(format string, a ...any) (string, error)

func DownloadAndRead

func DownloadAndRead(url string, fileName string) (string, time.Time, error)

func DownloadAndReadMaxMtime

func DownloadAndReadMaxMtime(url string, fileName string, maxMtime time.Time) (string, time.Time, error)

func ExtractData

func ExtractData(buf string) (int, int, int, error)

func ExtractRunData

func ExtractRunData(buf string) (int, int, error)

func ExtractVolData

func ExtractVolData(buf string) (int, error)

func GetParkrunnerCountry

func GetParkrunnerCountry(id string, eventCountries map[string]string) (string, error)

func Milestone

func Milestone(number int64) bool

func ParseAgeGroup

func ParseAgeGroup(s string) (string, int, error)

Types

type AchievementEnum

type AchievementEnum int64
const (
	AchievementNone AchievementEnum = iota
	AchievementFirst
	AchievementPB
)

func ParseAchievement

func ParseAchievement(s string, country string) (AchievementEnum, error)

type Event

type Event struct {
	Id         string
	Name       string
	CountryUrl string
	Country    string
	IsComplete bool
	Runs       []*Run
}

func AllEvents

func AllEvents() ([]*Event, error)

func LookupEvent

func LookupEvent(eventId string) (*Event, error)

func (*Event) Complete

func (event *Event) Complete() error

func (*Event) GetActiveParkrunners

func (event *Event) GetActiveParkrunners(minActiveRatio float64, examineNumberOfRuns uint64) ([]*Parkrunner, uint64, error)

func (*Event) GetStats

func (event *Event) GetStats() *EventStats

func (*Event) IsJuniorParkrun

func (event *Event) IsJuniorParkrun() bool

func (Event) NumberOfRuns

func (event Event) NumberOfRuns() int

type EventStats

type EventStats struct {
	FirstEvent []*Participant
	PB         []*Participant
	R1         []*Participant
	R25        []*Participant
	R50        []*Participant
	R100       []*Participant
	R150       []*Participant
	R200       []*Participant
	R250       []*Participant
	R300       []*Participant
	R350       []*Participant
	R400       []*Participant
	R450       []*Participant
	R500       []*Participant
	R550       []*Participant
	R600       []*Participant
	R650       []*Participant
	R700       []*Participant
	V1         []*Participant
	V25        []*Participant
	V50        []*Participant
	V100       []*Participant
	V150       []*Participant
	V200       []*Participant
	V250       []*Participant
	V300       []*Participant
	V350       []*Participant
	V400       []*Participant
	V450       []*Participant
	V500       []*Participant
	V550       []*Participant
	V600       []*Participant
	V650       []*Participant
	V700       []*Participant
}

type Parkrunner

type Parkrunner struct {
	Id         string
	Name       string
	AgeGroup   string
	DataTime   time.Time
	Runs       int64
	JuniorRuns int64
	Vols       int64
	Active     map[uint64]bool
}

func (*Parkrunner) FetchMissingStats

func (parkrunner *Parkrunner) FetchMissingStats(lastRunTime time.Time) error

func (*Parkrunner) NeedsUpdate

func (parkrunner *Parkrunner) NeedsUpdate() bool

type Participant

type Participant struct {
	Id          string
	Name        string
	AgeGroup    string
	Sex         int
	Runs        int64
	Vols        int64
	Time        time.Duration
	Achievement AchievementEnum
}

type Run

type Run struct {
	Parent      *Event
	Index       uint64
	Time        time.Time
	IsComplete  bool
	DataTime    time.Time
	NRunners    uint64
	NVolunteers uint64
	Runners     []*Participant
	Volunteers  []*Participant
}

func CreateRun

func CreateRun(parent *Event, index uint64, t time.Time, nFinishers, nVolunteers uint64) *Run

func (*Run) Complete

func (run *Run) Complete() error

Jump to

Keyboard shortcuts

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