internal

package
v0.0.0-...-5bec355 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StoreDynamicSecrets

func StoreDynamicSecrets(s *DynamicSecrets) error

Types

type Api

type Api struct {
	// contains filtered or unexported fields
}

func NewApi

func NewApi(logger *zap.Logger, ctx context.Context, conf *Config, s *StaticSecrets) (*Api, error)

func (*Api) FetchStandings

func (a *Api) FetchStandings(contest Contest) (*Standings, error)

type Config

type Config struct {
	ListenAddr           string        `json:"listen_addr"`
	SecureListenAddr     string        `json:"secure_listen_addr"`
	AllowedSecureDomains []string      `json:"allowed_secure_domains"`
	BaseURL              string        `json:"base_url"`
	Contests             []Contest     `json:"contests"`
	RefreshDuration      time.Duration `json:"refresh_duration"`
	ErrorRefreshDuration time.Duration `json:"error_refresh_duration"`
	StandingsForJudge    bool          `json:"standings_for_judge"`
	PageSize             int           `json:"page_size"`
	LoginWhitelistRegex  *string       `json:"login_whitelist_regex"`
	LoginBlacklistRegex  *string       `json:"login_blacklist_regex"`
	MaxScorePerTask      *float64      `json:"max_score_per_task"`
	DisplayNames         bool          `json:"display_names"`
	DisplayTeams         bool          `json:"display_teams"`
	Teams                []TeamConfig  `json:"teams"`
}

func LoadConfig

func LoadConfig() (*Config, error)

func (*Config) FillDefaults

func (c *Config) FillDefaults()

type Contest

type Contest struct {
	ID  int    `json:"id"`
	Tag string `json:"tag"`
}

type DynamicSecrets

type DynamicSecrets struct {
	Token *oauth2.Token `json:"token"`
}

func LoadDynamicSecrets

func LoadDynamicSecrets() (*DynamicSecrets, error)

type FilterMode

type FilterMode int
const (
	FilterModeWhitelist FilterMode = iota
	FilterModeBlacklist
)
type Header struct {
	Tasks []TaskHeader `json:"tasks"`
}

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(conf *Config, api *Api) (*Keeper, error)

func (*Keeper) Get

func (k *Keeper) Get(ctx context.Context, logger *zap.Logger) (*Standings, error)

type Participant

type Participant struct {
	Login  string            `json:"login"`
	Name   string            `json:"name"`
	TeamID int               `json:"team_id"`
	Tasks  []ParticipantCell `json:"tasks"`
	Total  float64           `json:"total"`
}

type ParticipantCell

type ParticipantCell struct {
	Score float64 `json:"score"`
}

type Presenter

type Presenter struct {
	// contains filtered or unexported fields
}

func NewPresenter

func NewPresenter(ctx context.Context, logger *zap.Logger, k *Keeper, conf *Config) (*Presenter, error)

func (*Presenter) ServeHTTP

func (p *Presenter) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Standings

type Standings struct {
	Tag          string        `json:"tag"`
	Header       Header        `json:"header"`
	Participants []Participant `json:"participants"`
}

func MergeStandings

func MergeStandings(logger *zap.Logger, sts ...*Standings) (*Standings, error)

func (*Standings) FilterPrefix

func (s *Standings) FilterPrefix(loginPrefix string, mode FilterMode) *Standings

func (*Standings) FilterRegex

func (s *Standings) FilterRegex(loginRegex string, mode FilterMode) (*Standings, error)

func (*Standings) FilterTeam

func (s *Standings) FilterTeam(teamID int) *Standings

func (*Standings) ValidateAndFix

func (s *Standings) ValidateAndFix() error

type StaticSecrets

type StaticSecrets struct {
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
}

func LoadStaticSecrets

func LoadStaticSecrets() (*StaticSecrets, error)

type TaskHeader

type TaskHeader struct {
	Name  string `json:"name"`
	Title string `json:"title"`
}

type TeamAssigner

type TeamAssigner struct {
	// contains filtered or unexported fields
}

func NewTeamAssigner

func NewTeamAssigner(conf *Config) (*TeamAssigner, error)

func (*TeamAssigner) AssignTeam

func (t *TeamAssigner) AssignTeam(p Participant) Participant

type TeamConfig

type TeamConfig struct {
	Name     string   `json:"name"`
	Patterns []string `json:"patterns"`
	Logins   []string `json:"logins"`
}

Jump to

Keyboard shortcuts

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