From c53dc767fd15f89e58d853603cb187c08538b62c Mon Sep 17 00:00:00 2001 From: Patrick Fairbank Date: Sat, 14 Sep 2019 14:15:35 -0700 Subject: [PATCH] Don't show matches after breaks in queueing display. --- web/queueing_display.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/web/queueing_display.go b/web/queueing_display.go index 90ccc9b..37ec790 100644 --- a/web/queueing_display.go +++ b/web/queueing_display.go @@ -10,9 +10,11 @@ import ( "github.com/Team254/cheesy-arena/model" "github.com/Team254/cheesy-arena/websocket" "net/http" + "time" ) const numMatchesToShow = 5 +const maxGapMin = 20 // Renders the queueing display that shows upcoming matches and timing information. func (web *Web) queueingDisplayHandler(w http.ResponseWriter, r *http.Request) { @@ -26,7 +28,7 @@ func (web *Web) queueingDisplayHandler(w http.ResponseWriter, r *http.Request) { return } var upcomingMatches []model.Match - for _, match := range matches { + for i, match := range matches { if match.Status == "complete" { continue } @@ -34,6 +36,11 @@ func (web *Web) queueingDisplayHandler(w http.ResponseWriter, r *http.Request) { if len(upcomingMatches) == numMatchesToShow { break } + + // Don't include any more matches if there is a significant gap before the next one. + if i+1 < len(matches) && matches[i+1].Time.Sub(match.Time) > maxGapMin*time.Minute { + break + } } template, err := web.parseFiles("templates/queueing_display.html")