Skip to content

Commit

Permalink
Parse out school name and show it in the announcer display.
Browse files Browse the repository at this point in the history
  • Loading branch information
patfair committed May 23, 2024
1 parent def8c0e commit e17cc8f
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions model/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Team struct {
City string
StateProv string
Country string
SchoolName string
RookieYear int
RobotName string
Accomplishments string
Expand Down
4 changes: 2 additions & 2 deletions static/js/announcer_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ var handleMatchTime = function(data) {

// Handles a websocket message to update the match score.
var handleRealtimeScore = function(data) {
$("#redScore").text(data.Red.ScoreSummary.Score - data.Red.ScoreSummary.EndgamePoints);
$("#blueScore").text(data.Blue.ScoreSummary.Score - data.Blue.ScoreSummary.EndgamePoints);
$("#redScore").text(data.Red.ScoreSummary.Score - data.Red.ScoreSummary.StagePoints);
$("#blueScore").text(data.Blue.ScoreSummary.Score - data.Blue.ScoreSummary.StagePoints);
};

// Handles a websocket message to populate the final score data.
Expand Down
5 changes: 3 additions & 2 deletions templates/announcer_display.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ <h3 id="matchName" class="mt-4"></h3>
<div class="row card card-body border-0">
<div class="row">
<div class="col-sm-2"><h4>Team #</h4></div>
<div class="col-sm-5"><h4>Nickname</h4></div>
<div class="col-sm-5"><h4>Location</h4></div>
<div class="col-sm-4"><h4>Nickname</h4></div>
<div class="col-sm-2"><h4>School</h4></div>
<div class="col-sm-4"><h4>Location</h4></div>
</div>
</div>
<div id="teams"></div>
Expand Down
7 changes: 4 additions & 3 deletions templates/announcer_display_match_load.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ <h4><b>Alliance {{.Match.PlayoffBlueAlliance}}</b></h4>
<div class="row">
{{if .team}}
<div class="col-sm-2"><h2><b>{{.team.Id}}</b>{{if .isOffField}} (not on field){{end}}</h2></div>
<div class="col-sm-5"><h2>{{.team.Nickname}}</h2></div>
<div class="col-sm-4">
<div><h4>{{.team.City}}, {{.team.StateProv}}, {{.team.Country}}</h4></div>
<div class="col-sm-4"><h2>{{.team.Nickname}}</h2></div>
<div class="col-sm-2"><h5>{{.team.SchoolName}}</h5></div>
<div class="col-sm-3">
<div><h5>{{.team.City}}, {{.team.StateProv}}, {{.team.Country}}</h5></div>
</div>
<div class="col-sm-1">
<button type="button" class="btn btn-secondary btn-sm" onclick="$('#team{{.team.Id}}Details').modal('show');">
Expand Down
2 changes: 2 additions & 0 deletions templates/setup_teams.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<th>#</th>
<th>Name</th>
<th>Nickname</th>
<th>School</th>
<th>Location</th>
<th>Rookie Year</th>
<th>Robot Name</th>
Expand All @@ -74,6 +75,7 @@
<td>{{$team.Id}}</td>
<td>{{$team.Name}}</td>
<td>{{$team.Nickname}}</td>
<td>{{$team.SchoolName}}</td>
<td>{{$team.City}}, {{$team.StateProv}}, {{$team.Country}}</td>
<td>{{$team.RookieYear}}</td>
<td>{{$team.RobotName}}</td>
Expand Down
6 changes: 6 additions & 0 deletions web/setup_teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/Team254/cheesy-arena/model"
"github.com/dchest/uniuri"
"net/http"
"regexp"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -307,6 +308,11 @@ func (web *Web) populateOfficialTeamInfo(team *model.Team) error {
team.City = tbaTeam.City
team.StateProv = tbaTeam.StateProv
team.Country = tbaTeam.Country
schoolNameRe := regexp.MustCompile("^.*\\S&(\\S.*?$)")
matches := schoolNameRe.FindStringSubmatch(tbaTeam.Name)
if len(matches) > 0 {
team.SchoolName = matches[1]
}
team.RookieYear = tbaTeam.RookieYear
team.RobotName, err = web.arena.TbaClient.GetRobotName(team.Id, time.Now().Year())
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion web/setup_teams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestSetupTeams(t *testing.T) {
// Mock the URL to download team info from.
teamInfoBody := `{
"website": "http://www.team254.com",
"name": "NASA Ames Research Center",
"name": "NASA Ames Research Center/PG&E&Bellarmine College Preparatory",
"city": "San Jose",
"rookie_year": 1999,
"state_prov": "CA",
Expand Down Expand Up @@ -90,6 +90,8 @@ func TestSetupTeams(t *testing.T) {
assert.Contains(t, recorder.Body.String(), "2 teams")
assert.Contains(t, recorder.Body.String(), "The Cheesy Poofs")
assert.Contains(t, recorder.Body.String(), "1114")
team, _ := web.arena.Database.GetTeamById(254)
assert.Equal(t, "Bellarmine College Preparatory", team.SchoolName)

// Add another team.
recorder = web.postHttpResponse("/setup/teams", "teamNumbers=33")
Expand Down

0 comments on commit e17cc8f

Please sign in to comment.