Show cancelled schedule status

This commit is contained in:
2026-07-03 02:57:18 -04:00
parent 85a8b6ad44
commit c973c03689
20 changed files with 173 additions and 29 deletions

View File

@@ -23,6 +23,8 @@ func meetingToModel(m store.Meeting) models.Meeting {
DateStart: m.DateStart,
DateEnd: m.DateEnd,
Year: m.Year,
IsCancelled: m.IsCancelled,
}
}
@@ -36,6 +38,8 @@ func sessionToModel(s store.Session) models.Session {
DateStart: s.DateStart,
DateEnd: s.DateEnd,
GMTOffset: s.GMTOffset,
IsCancelled: s.IsCancelled,
}
}

View File

@@ -55,3 +55,23 @@ func datasetsFromCounts(meetingAvailable, sessionAvailable bool, counts store.Se
}
return ds
}
func cancelledDatasets() map[string]DatasetInfo {
ds := emptyDatasetMap()
ds["meeting"] = availableLocal(1)
ds["session"] = availableLocal(1)
for _, key := range []string{
"drivers",
"results",
"starting_grid",
"stints",
"pit_stops",
"positions",
"race_control",
"weather",
"laps",
} {
ds[key] = skippedNA()
}
return ds
}

View File

@@ -10,9 +10,10 @@ const (
DataSourceNone = "none"
DataSourceOpenF1 = "openf1"
ResponseSourceLocal = "local"
ResponseSourceNone = "none"
ResponseSourcePartial = "partial"
ResponseSourceLocal = "local"
ResponseSourceNone = "none"
ResponseSourcePartial = "partial"
ResponseSourceCancelled = "cancelled"
)
// DatasetInfo describes availability of a single dataset.

View File

@@ -5,6 +5,7 @@ import (
"errors"
"github.com/AmanTahiliani/box-box/internal/models"
"github.com/AmanTahiliani/box-box/internal/store"
)
// ErrMeetingNotFound is returned when a meeting is not in the local store.
@@ -65,21 +66,35 @@ func (s *Service) GetWeekend(meetingKey int) (Weekend, error) {
}
datasets := datasetsFromCounts(true, true, counts)
sessionModel := sessionToModel(sess)
if sess.IsCancelled {
datasets = cancelledDatasets()
}
if datasets["starting_grid"].Status == DatasetStatusMissing && !isGridExpected(sessionModel.SessionType, sessionModel.SessionName) {
datasets["starting_grid"] = skippedNA()
}
out.Sessions = append(out.Sessions, WeekendSession{
Session: sessionModel,
Source: responseSource(datasets),
Source: sessionSource(sess, datasets),
Datasets: datasets,
})
}
out.Source = weekendSource(out.Sessions)
if meeting.IsCancelled {
out.Source = ResponseSourceCancelled
} else {
out.Source = weekendSource(out.Sessions)
}
out.DefaultSessionKey = pickDefaultSession(out.Sessions)
return out, nil
}
func sessionSource(sess store.Session, datasets map[string]DatasetInfo) string {
if sess.IsCancelled {
return ResponseSourceCancelled
}
return responseSource(datasets)
}
func weekendSource(sessions []WeekendSession) string {
if len(sessions) == 0 {
return ResponseSourceNone

View File

@@ -106,6 +106,12 @@ func (s *Service) GetRaceHub(sessionKey int) (RaceHub, error) {
hub.Datasets["meeting"] = availableLocal(1)
}
if sess.IsCancelled || (hub.Meeting != nil && hub.Meeting.IsCancelled) {
hub.Source = ResponseSourceCancelled
hub.Datasets = cancelledDatasets()
return hub, nil
}
driverLinks, err := s.store.ListSessionDrivers(sessionKey)
if err != nil {
return RaceHub{}, err