Don't show matches after breaks in queueing display.

This commit is contained in:
Patrick Fairbank
2019-09-14 14:15:35 -07:00
parent b9e061904f
commit c53dc767fd

View File

@@ -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")