Skip to content

Commit

Permalink
Merge pull request #1013 from JustaPenguin/show-all-races-in-recents
Browse files Browse the repository at this point in the history
all races now show up in recent races on custom race page
  • Loading branch information
cj123 authored Sep 14, 2020
2 parents 9e2947e + 14603b6 commit 7699e0e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
5 changes: 5 additions & 0 deletions race_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ func (rc *RaceControl) watchForTimedOutDrivers() {
func (rc *RaceControl) OnVersion(version udp.Version) error {
go panicCapture(rc.requestSessionInfo)

// clear chat messages on new server start
rc.ChatMessagesMutex.Lock()
rc.ChatMessages = []udp.Chat{}
rc.ChatMessagesMutex.Unlock()

_, err := rc.broadcaster.Send(version)

return err
Expand Down
14 changes: 4 additions & 10 deletions race_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ func (rm *RaceManager) BuildRaceOpts(r *http.Request) (*RaceTemplateVars, error)
return opts, nil
}

const maxRecentRaces = 30
const maxRecentRaces = 40

func (rm *RaceManager) ListCustomRaces() (recent, starred, looped, scheduled []*CustomRace, err error) {
recent, err = rm.store.ListCustomRaces()
Expand All @@ -1110,8 +1110,6 @@ func (rm *RaceManager) ListCustomRaces() (recent, starred, looped, scheduled []*
return recent[i].Updated.After(recent[j].Updated)
})

var filteredRecent []*CustomRace

for _, race := range recent {
if race.IsLooping() {
looped = append(looped, race)
Expand Down Expand Up @@ -1142,17 +1140,13 @@ func (rm *RaceManager) ListCustomRaces() (recent, starred, looped, scheduled []*
if race.Scheduled.After(time.Now()) && race.ScheduledServerID == serverID {
scheduled = append(scheduled, race)
}

if !race.Starred && !race.IsLooping() && !race.Scheduled.After(time.Now()) {
filteredRecent = append(filteredRecent, race)
}
}

if len(filteredRecent) > maxRecentRaces {
filteredRecent = filteredRecent[:maxRecentRaces]
if len(recent) > maxRecentRaces {
recent = recent[:maxRecentRaces]
}

return filteredRecent, starred, looped, scheduled, nil
return recent, starred, looped, scheduled, nil
}

func (rm *RaceManager) SaveEntrantsForAutoFill(entryList EntryList) error {
Expand Down

0 comments on commit 7699e0e

Please sign in to comment.