package models import ( "time" ) // Group represents a racer group (e.g., age group, division) type Group struct { ID int64 `json:"id"` Name string `json:"name"` Description string `json:"description"` CreatedAt time.Time `json:"created_at"` } // Racer represents a derby racer type Racer struct { ID int64 `json:"id"` FirstName string `json:"first_name"` LastName string `json:"last_name"` CarNumber string `json:"car_number"` CarWeight float64 `json:"car_weight"` GroupID int64 `json:"group_id"` GroupName string `json:"group_name,omitempty"` // For display purposes CreatedAt time.Time `json:"created_at"` } // Race represents a derby race event type Race struct { ID int64 `json:"id"` Name string `json:"name"` Status string `json:"status"` // pending, running, completed CreatedAt time.Time `json:"created_at"` } // RaceResult represents the result of a racer in a race type RaceResult struct { ID int64 `json:"id"` RaceID int64 `json:"race_id"` RacerID int64 `json:"racer_id"` Lane int `json:"lane"` Time *float64 `json:"time,omitempty"` Place *int `json:"place,omitempty"` CreatedAt time.Time `json:"created_at"` } // Heat represents a single race with 4 lanes type Heat struct { ID int64 `json:"id"` GroupID int64 `json:"group_id"` HeatNum int `json:"heat_num"` Lane1ID *int64 `json:"lane1_id"` Lane2ID *int64 `json:"lane2_id"` Lane3ID *int64 `json:"lane3_id"` Lane4ID *int64 `json:"lane4_id"` } // HeatResult represents the result of a heat type HeatResult struct { GroupID int64 `json:"group_id"` HeatNumber int `json:"heat_number"` Lane1Time float64 `json:"lane1_time"` Lane1Position int `json:"lane1_position"` Lane2Time float64 `json:"lane2_time"` Lane2Position int `json:"lane2_position"` Lane3Time float64 `json:"lane3_time"` Lane3Position int `json:"lane3_position"` Lane4Time float64 `json:"lane4_time"` Lane4Position int `json:"lane4_position"` } type LaneData struct { Lane int RacerID int64 Name string CarNum string CarWeight float64 Time float64 Place int } type HeatData struct { Group Group HeatNumber int TotalHeats int Lane1 *LaneData Lane2 *LaneData Lane3 *LaneData Lane4 *LaneData } // Event types that can be sent on the event channel type AdminEventType int const ( EventHeatChanged AdminEventType = iota EventGroupChanged EventHeatRerun EventResultsReveal ) // Event represents a race event type AdminEvent struct { Type AdminEventType Event any } // FinalResult represents a racer's final result in a group type FinalResult struct { Racer Racer `json:"racer"` Times []float64 `json:"times"` AverageTime float64 `json:"average_time"` Place int `json:"place"` DNF bool `json:"dnf"` }