Add leaderboard for all tracks and track calendar

This commit is contained in:
2026-07-15 11:53:35 +04:00
parent 4a894a4399
commit a56841237d
20 changed files with 1394 additions and 25 deletions
+37
View File
@@ -362,6 +362,7 @@ type TrackWire struct {
BestLapHolder string `json:"best_lap_holder,omitempty"`
CreatedMs int64 `json:"created_ms"`
UpdatedMs int64 `json:"updated_ms"`
IsActive bool `json:"is_active" example:"true"`
}
// TrackListRequest: payload { "scope": "all|system|public|private", "tag": "..." }.
@@ -862,6 +863,42 @@ type LeaderboardResponse struct {
CurrentDriver *LeaderboardEntry `json:"current_driver,omitempty"`
}
// TrackCalendarEntry is the wire representation of an active track schedule period.
type TrackCalendarEntry struct {
ID int `json:"id" example:"1"`
TrackID string `json:"track_id" example:"monaco"`
StartAt time.Time `json:"start_at" example:"2026-07-15T00:00:00Z"`
EndAt time.Time `json:"end_at" example:"2026-07-30T00:00:00Z"`
}
// TrackCalendarCreateRequest is the payload to schedule a track active period.
type TrackCalendarCreateRequest struct {
TrackID string `json:"track_id" example:"monaco"`
StartAt time.Time `json:"start_at" example:"2026-07-15T00:00:00Z"`
EndAt time.Time `json:"end_at" example:"2026-07-30T00:00:00Z"`
}
// TrackCalendarResponse is the wrapper for the calendar list.
type TrackCalendarResponse struct {
Items []TrackCalendarEntry `json:"items"`
}
// TrackCalendarLeaderboard holds the leaderboard summary for a track calendar event.
type TrackCalendarLeaderboard struct {
TrackID string `json:"track_id" example:"monaco"`
TrackName string `json:"track_name" example:"Monaco"`
StartAt time.Time `json:"start_at" example:"2026-07-15T00:00:00Z"`
EndAt time.Time `json:"end_at" example:"2026-07-30T00:00:00Z"`
Status string `json:"status" example:"active"`
Podium []LeaderboardEntry `json:"podium"`
CurrentDriver *LeaderboardEntry `json:"current_driver,omitempty"`
}
// TrackCalendarLeaderboardResponse is the list response for calendar leaderboards.
type TrackCalendarLeaderboardResponse struct {
Items []TrackCalendarLeaderboard `json:"items"`
}
// Encode marshals an envelope to JSON bytes.
func Encode(env *Envelope) ([]byte, error) {
if env.TSMs == 0 {