mirror of
https://github.com/AmanTahiliani/box-box.git
synced 2026-08-07 19:56:18 -04:00
feat: add narrative chapter headlines and race-hub chapter strip (#21)
Generate deterministic template headlines server-side for each replay chapter kind, expose Chapter.headline in the race-hub payload, and render a horizontal chapter strip on the story view with active-chapter highlighting, click-to-jump, and a 90-second tour mode built on the existing scrubber playback. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -252,10 +252,38 @@ func (s *Service) GetRaceHub(sessionKey int) (RaceHub, error) {
|
||||
}
|
||||
|
||||
hub.Chapters = chapters.Detect(hub.RaceControl, hub.Positions, hub.Laps, totalLaps(hub.Results, hub.Laps))
|
||||
hub.Chapters = chapters.ApplyHeadlines(
|
||||
hub.Chapters,
|
||||
chapters.BuildDriverMap(hub.Drivers, driverIdentityInputs(hub.Results)),
|
||||
hub.RaceControl,
|
||||
winnerDriverNumber(hub.Results),
|
||||
)
|
||||
hub.Source = responseSource(hub.Datasets)
|
||||
return hub, nil
|
||||
}
|
||||
|
||||
func driverIdentityInputs(results []EnrichedResult) []chapters.DriverIdentityInput {
|
||||
out := make([]chapters.DriverIdentityInput, 0, len(results))
|
||||
for _, r := range results {
|
||||
out = append(out, chapters.DriverIdentityInput{
|
||||
DriverNumber: r.DriverNumber,
|
||||
NameAcronym: r.NameAcronym,
|
||||
FullName: r.FullName,
|
||||
TeamName: r.TeamName,
|
||||
})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func winnerDriverNumber(results []EnrichedResult) int {
|
||||
for _, r := range results {
|
||||
if r.Position == 1 {
|
||||
return r.DriverNumber
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func totalLaps(results []EnrichedResult, laps []models.Lap) int {
|
||||
total := 0
|
||||
for _, result := range results {
|
||||
|
||||
Reference in New Issue
Block a user