driver

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeRequired        = "required"
	ErrCodeInvalidInteger  = "invalid_integer"
	ErrCodePositiveInteger = "positive_integer"
	ErrCodeInvalidISO8601  = "invalid_iso8601"
	ErrCodeEndBeforeStart  = "end_before_start"
	ErrCodeInvalidValue    = "invalid_value"
	ErrCodeMutualExclusive = "mutual_exclusive"
)

Error codes for i18n support

Variables

This section is empty.

Functions

func NewAnalyticsDimensionsEndpoint

func NewAnalyticsDimensionsEndpoint(svc AnalyticsService) http.Handler

NewAnalyticsDimensionsEndpoint creates the handler for GET /driver/{driver_id}/analytics/dimensions

func NewAnalyticsEndpoint

func NewAnalyticsEndpoint(svc AnalyticsService) http.Handler

NewAnalyticsEndpoint creates the handler for GET /driver/{driver_id}/analytics

func NewDeleteJournalEntryEndpoint

func NewDeleteJournalEntryEndpoint(journalService DeleteJournalEntryStore) http.Handler

func NewDeleteRacesEndpoint

func NewDeleteRacesEndpoint(store DeleteRacesStore) http.Handler

func NewGetDriverEndpoint

func NewGetDriverEndpoint(driverStore GetDriverStore) http.Handler

func NewGetJournalEntryEndpoint

func NewGetJournalEntryEndpoint(journalService GetJournalEntryStore) http.Handler

func NewGetRaceEndpoint

func NewGetRaceEndpoint(raceStore GetRaceStore) http.Handler

func NewGetRacesEndpoint

func NewGetRacesEndpoint(raceStore GetRacesStore) http.Handler

func NewListJournalEntriesEndpoint

func NewListJournalEntriesEndpoint(journalService ListJournalEntriesStore) http.Handler

func NewRouter

func NewRouter(raceStore Store, journalService JournalService, analyticsService AnalyticsService, authMiddleware, developerMiddleware func(http.Handler) http.Handler) http.Handler

func NewSaveJournalEndpoint

func NewSaveJournalEndpoint(journalService JournalServiceForSave) http.Handler

Types

type AnalyticsGroup

type AnalyticsGroup struct {
	// Dimension identifiers - populated based on groupBy dimensions
	// Frontend uses reference endpoints (/series, /cars, /tracks) for names
	SeriesID *int64 `json:"seriesId,omitempty"`
	CarID    *int64 `json:"carId,omitempty"`
	TrackID  *int64 `json:"trackId,omitempty"`

	Summary AnalyticsSummary `json:"summary"`
}

AnalyticsGroup represents aggregated stats for a specific dimension combination.

type AnalyticsPeriod

type AnalyticsPeriod struct {
	Period  string           `json:"period"` // Format based on granularity: "2024-01-15", "2024-W03", "2024-01", "2024"
	Summary AnalyticsSummary `json:"summary"`
}

AnalyticsPeriod represents aggregated stats for a time period.

type AnalyticsResponse

type AnalyticsResponse struct {
	Summary    AnalyticsSummary  `json:"summary"`
	GroupedBy  []AnalyticsGroup  `json:"groupedBy,omitempty"`  // if groupBy specified
	TimeSeries []AnalyticsPeriod `json:"timeSeries,omitempty"` // if granularity specified
}

AnalyticsResponse is the response for the analytics endpoint.

type AnalyticsService

type AnalyticsService interface {
	GetDimensions(ctx context.Context, driverID int64, from, to time.Time) (*analytics.Dimensions, error)
	GetAnalytics(ctx context.Context, req analytics.AnalyticsRequest) (*analytics.AnalyticsResult, error)
}

AnalyticsService defines the interface for analytics operations.

type AnalyticsSummary

type AnalyticsSummary struct {
	RaceCount int `json:"raceCount"`

	// iRating
	IRatingStart int `json:"iRatingStart"` // first race in range
	IRatingEnd   int `json:"iRatingEnd"`   // last race in range
	IRatingDelta int `json:"iRatingDelta"` // net change
	IRatingGain  int `json:"iRatingGain"`  // sum of positive deltas
	IRatingLoss  int `json:"iRatingLoss"`  // sum of negative deltas (as positive number)

	// CPI (Compliance Points Index) - frontend formats as SR for display
	CPIStart float64 `json:"cpiStart"` // CPI at first race
	CPIEnd   float64 `json:"cpiEnd"`   // CPI at last race
	CPIDelta float64 `json:"cpiDelta"` // net CPI change
	CPIGain  float64 `json:"cpiGain"`  // sum of positive CPI deltas
	CPILoss  float64 `json:"cpiLoss"`  // sum of negative CPI deltas

	// Position stats
	Podiums           int     `json:"podiums"`           // finish <= 3
	Top5Finishes      int     `json:"top5Finishes"`      // finish <= 5
	Wins              int     `json:"wins"`              // finish == 1
	AvgFinishPosition float64 `json:"avgFinishPosition"` // average finish position
	AvgStartPosition  float64 `json:"avgStartPosition"`  // average qualifying position
	PositionsGained   float64 `json:"positionsGained"`   // avg (start - finish), positive = gained

	// Incidents
	TotalIncidents int     `json:"totalIncidents"`
	AvgIncidents   float64 `json:"avgIncidents"`
}

AnalyticsSummary contains aggregated statistics for a set of races.

type DeleteJournalEntryStore

type DeleteJournalEntryStore interface {
	Delete(ctx context.Context, driverID, raceID int64) error
}

type DeleteRacesStore

type DeleteRacesStore interface {
	DeleteDriverRaces(ctx context.Context, driverID int64) error
}

type DimensionsResponse

type DimensionsResponse struct {
	Series []int64 `json:"series"`
	Cars   []int64 `json:"cars"`
	Tracks []int64 `json:"tracks"`
}

DimensionsResponse is the response for the dimensions endpoint. Returns IDs only - frontend uses reference endpoints (/series, /cars, /tracks) for details.

type DriverInfo

type DriverInfo struct {
	DriverID              int64      `json:"driverId"`
	DriverName            string     `json:"driverName"`
	MemberSince           time.Time  `json:"memberSince"`
	RacesIngestedTo       *time.Time `json:"racesIngestedTo"`
	IngestionBlockedUntil *time.Time `json:"ingestionBlockedUntil"`
	FirstLogin            time.Time  `json:"firstLogin"`
	LastLogin             time.Time  `json:"lastLogin"`
	LoginCount            int64      `json:"loginCount"`
	SessionCount          int64      `json:"sessionCount"`
}

type GetDriverStore

type GetDriverStore interface {
	GetDriver(ctx context.Context, driverID int64) (*store.Driver, error)
}

type GetJournalEntryStore

type GetJournalEntryStore interface {
	Get(ctx context.Context, driverID, raceID int64) (*journal.Entry, error)
}

type GetRaceStore

type GetRaceStore interface {
	GetDriverSession(ctx context.Context, driverID int64, startTime time.Time) (*store.DriverSession, error)
}

type GetRacesStore

type GetRacesStore interface {
	GetDriverSessionsByTimeRange(ctx context.Context, driverID int64, from, to time.Time, filters ...store.SessionFilter) ([]store.DriverSession, error)
}

type JournalEntry

type JournalEntry struct {
	RaceID      int64     `json:"raceId"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`
	Notes       string    `json:"notes"`
	Tags        []string  `json:"tags"`
	ReplayVideo string    `json:"replayVideo,omitempty"`
	Race        *Race     `json:"race,omitempty"`
}

JournalEntry is the API response model for a journal entry with joined race context.

type JournalServiceForSave

type JournalServiceForSave interface {
	ValidateRaceExists(ctx context.Context, driverID, raceID int64) (bool, error)
	Save(ctx context.Context, input journal.SaveInput) (*journal.Entry, error)
}

type ListJournalEntriesStore

type ListJournalEntriesStore interface {
	List(ctx context.Context, input journal.ListInput) ([]journal.Entry, error)
}

type Race

type Race struct {
	ID                    int64     `json:"id"`
	SubsessionID          int64     `json:"subsessionId"`
	TrackID               int64     `json:"trackId"`
	SeriesID              int64     `json:"seriesId"`
	SeriesName            string    `json:"seriesName"`
	CarID                 int64     `json:"carId"`
	StartTime             time.Time `json:"startTime"`
	StartPosition         int       `json:"startPosition"`
	StartPositionInClass  int       `json:"startPositionInClass"`
	FinishPosition        int       `json:"finishPosition"`
	FinishPositionInClass int       `json:"finishPositionInClass"`
	Incidents             int       `json:"incidents"`
	OldCPI                float64   `json:"oldCpi"`
	NewCPI                float64   `json:"newCpi"`
	OldIRating            int       `json:"oldIrating"`
	NewIRating            int       `json:"newIrating"`
	OldLicenseLevel       int       `json:"oldLicenseLevel"`
	NewLicenseLevel       int       `json:"newLicenseLevel"`
	OldSubLevel           int       `json:"oldSubLevel"`
	NewSubLevel           int       `json:"newSubLevel"`
	ReasonOut             string    `json:"reasonOut"`
}

type SaveJournalEntryRequest

type SaveJournalEntryRequest struct {
	Notes       string   `json:"notes"`
	Tags        []string `json:"tags"`
	ReplayVideo string   `json:"replayVideo"`
}

SaveJournalEntryRequest is the request body for creating/updating a journal entry.

Jump to

Keyboard shortcuts

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