From 0abbd2cb3012ca3a44a8aa9c53a468ad4eb3513b Mon Sep 17 00:00:00 2001 From: henry Date: Fri, 10 Apr 2020 15:06:57 +0100 Subject: [PATCH] start time attack events properly if initiated from the custom race form, indicate that results are time attack in the results list --- cmd/server-manager/views/pages/results/index.html | 6 +++++- cmd/server-manager/views/pages/results/result.html | 2 +- race_manager.go | 5 +++++ results.go | 4 ++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cmd/server-manager/views/pages/results/index.html b/cmd/server-manager/views/pages/results/index.html index 961012311..bcc4bbf72 100644 --- a/cmd/server-manager/views/pages/results/index.html +++ b/cmd/server-manager/views/pages/results/index.html @@ -36,7 +36,11 @@

Results

{{ $result.GetDate }} - {{ $result.Type }} + {{ if $result.IsTimeAttack }} + Time Attack + {{ else }} + {{ $result.Type }} + {{ end }} {{ prettify $result.TrackName false }} diff --git a/cmd/server-manager/views/pages/results/result.html b/cmd/server-manager/views/pages/results/result.html index 08b29b735..1f6f54b0b 100644 --- a/cmd/server-manager/views/pages/results/result.html +++ b/cmd/server-manager/views/pages/results/result.html @@ -11,7 +11,7 @@ {{ $useMPH := .UseMPH }}

{{ prettify $sessionResults.TrackName false }} {{ with $sessionResults.TrackConfig }} - {{ prettify . true }} {{ end }}

-
{{ $sessionResults.GetDate }}
+
{{ if $sessionResults.IsTimeAttack }}Time Attack - {{ end }}{{ $sessionResults.GetDate }}
Back to Results diff --git a/race_manager.go b/race_manager.go index 7e4cdd51f..501aacac2 100644 --- a/race_manager.go +++ b/race_manager.go @@ -838,6 +838,11 @@ func (rm *RaceManager) SetupCustomRace(r *http.Request) error { return nil } + if race.RaceConfig.TimeAttack && Premium() { + logrus.Info("Time Attack event started") + rm.raceControl.currentTimeAttackEvent = race + } + if saveAsPresetWithoutStartingRace { return nil } diff --git a/results.go b/results.go index 02bc1bcb6..453bb8e16 100644 --- a/results.go +++ b/results.go @@ -91,6 +91,10 @@ func (s *SessionResults) Anonymize() { } } +func (s *SessionResults) IsTimeAttack() bool { + return strings.HasSuffix(s.SessionFile, timeAttackSuffix) +} + func AnonymiseDriverGUID(guid string) string { hasher := md5.New() _, _ = hasher.Write([]byte(guid))