mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 13:46:44 -04:00
Don't show matches after breaks in queueing display.
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user