scoring

package
v0.0.54 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

README

api/sinks/postgres/scoring

Read queries and initialization for the scoring tables. Score insertion lives in the sibling agent package; this package is responsible for seeding and reading.

Seeding populates the running-totals table at startup with a zero row for every team, box, and service combination — using insert-or-ignore so pre-existing counters are not reset on restart. Read queries cover five views at different levels of aggregation: most recent result per service (current status), totals per team, totals per box, totals per box and service, and a full three-level team/box/service breakdown. Also provides helpers for converting raw pass/total counts into a rounded uptime percentage.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCurrentServiceStatus

func GetCurrentServiceStatus(ctx context.Context, db *pgxpool.Pool, cfg *config.APIConfigSpec) ([]types.Score, error)

GetCurrentServiceStatus returns the entire recent scores table. It is sorted by team number, then box ID, then service ID.

func InitScoring

func InitScoring(ctx context.Context, db *pgxpool.Pool, cfg *config.APIConfigSpec) error

InitScoring creates rows in the final scores table for each team/box/service combo.

Types

type BoxScores

type BoxScores map[types.BoxName]types.ScoreResult

BoxScores is a map that can be used to quickly reference stats for a specific box.

func GetBoxScores

func GetBoxScores(ctx context.Context, db *pgxpool.Pool) (BoxScores, error)

GetBoxScores collates and calculates competion scores for all teams.

type DetailedScores

type DetailedScores map[types.TeamNum]ServiceScores

DetailedScores is a double-nested map that can be used to quickly reference stats for a specific teams' boxes' services. EXTREMELY ugly but i cant think of a better way to do this. this is a map[]map[]map[]. team_num -> box -> service.

func GetDetailedScores

func GetDetailedScores(ctx context.Context, db *pgxpool.Pool) (DetailedScores, error)

GetDetailedScores pulls the full final scoring data as it is stored in the db.

type ServiceScores

type ServiceScores map[types.BoxName]map[types.ServiceName]types.ScoreResult

ServiceScores is a nested map that can be used to quickly reference stats for a specific boxes' specific service. very ugly but i cant think of a better way to do this.

func GetServiceScores

func GetServiceScores(ctx context.Context, db *pgxpool.Pool) (ServiceScores, error)

GetServiceScores collates and calculates competion scores for each service on each box.

type TeamScores

type TeamScores map[types.TeamNum]types.ScoreResult

TeamScores is a map that can be used to quickly reference a specific teams stats.

func GetTeamScores

func GetTeamScores(ctx context.Context, db *pgxpool.Pool) (TeamScores, error)

GetTeamScores collates and calculates competion scores for all teams.

Jump to

Keyboard shortcuts

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