mirror of
https://github.com/IS1DI/x0gp.git
synced 2026-07-19 05:47:02 +00:00
Add races results GET endpoints (by ID and last finished) and regenerate swagger specs
This commit is contained in:
@@ -812,6 +812,31 @@ func (s *Service) GetCalendarLeaderboard(ctx context.Context, year int, currentD
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// GetRace fetches a single race by id (either live from lobby or finished from DB).
|
||||
func (s *Service) GetRace(ctx context.Context, id string) (FinishedRace, error) {
|
||||
meta, err := s.lobby.GetRace(id)
|
||||
if err == nil {
|
||||
return FinishedRace{
|
||||
ID: meta.ID,
|
||||
Name: meta.Name,
|
||||
TrackID: meta.TrackID,
|
||||
MaxCars: meta.MaxCars,
|
||||
Laps: meta.Laps,
|
||||
TimeLimitS: meta.TimeLimitS,
|
||||
DriverIDs: meta.DriverIDs,
|
||||
Status: string(meta.Status),
|
||||
CreatedMs: meta.CreatedMs,
|
||||
StartedMs: meta.StartedMs,
|
||||
}, nil
|
||||
}
|
||||
return s.pg.GetFinished(ctx, id)
|
||||
}
|
||||
|
||||
// GetLastFinished fetches the most recently finished race.
|
||||
func (s *Service) GetLastFinished(ctx context.Context) (FinishedRace, error) {
|
||||
return s.pg.GetLastFinished(ctx)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Scheduler
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user