From 3d566f48667c21364e68c24e243783e626b3ef76 Mon Sep 17 00:00:00 2001 From: Patrick Fairbank Date: Sun, 11 Sep 2022 12:59:07 -0700 Subject: [PATCH] Set display name when pushing double-elimination matches to TBA. --- partner/tba.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/partner/tba.go b/partner/tba.go index 47d09fbe..3bb223da 100755 --- a/partner/tba.go +++ b/partner/tba.go @@ -15,6 +15,7 @@ import ( "io/ioutil" "net/http" "strconv" + "strings" ) const ( @@ -38,6 +39,7 @@ type TbaMatch struct { Alliances map[string]*TbaAlliance `json:"alliances"` TimeString string `json:"time_string"` TimeUtc string `json:"time_utc"` + DisplayName string `json:"display_name"` } type TbaAlliance struct { @@ -331,8 +333,14 @@ func (client *TbaClient) PublishMatches(database *model.Database) error { alliances["blue"] = createTbaAlliance([3]int{match.Blue1, match.Blue2, match.Blue3}, [3]bool{match.Blue1IsSurrogate, match.Blue2IsSurrogate, match.Blue3IsSurrogate}, blueScore) - tbaMatches[i] = TbaMatch{"qm", 0, matchNumber, alliances, match.Time.Local().Format("3:04 PM"), - match.Time.UTC().Format("2006-01-02T15:04:05")} + tbaMatches[i] = TbaMatch{ + CompLevel: "qm", + SetNumber: 0, + MatchNumber: matchNumber, + Alliances: alliances, + TimeString: match.Time.Local().Format("3:04 PM"), + TimeUtc: match.Time.UTC().Format("2006-01-02T15:04:05"), + } if match.Type == "elimination" { setElimMatchKey(&tbaMatches[i], &match, eventSettings.ElimType) } @@ -553,5 +561,8 @@ func setElimMatchKey(tbaMatch *TbaMatch, match *model.Match, elimType string) { tbaMatch.SetNumber = tbaKey.setNumber } tbaMatch.MatchNumber = match.ElimInstance + if !strings.HasPrefix(match.DisplayName, "F") { + tbaMatch.DisplayName = "Match " + match.DisplayName + } } }