scouting: Hack up team parsing to get Madtown working
We have teams like "1678E" which our code is unable to parse.
This hack removes the letter suffix and turns it into multiple of
10000 to add to the team number.
We should switch the team numbers to be strings in the future.
Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: I09c6e097b7014f244fc3d9bd45a792fe7d04056c
diff --git a/scouting/webserver/requests/requests.go b/scouting/webserver/requests/requests.go
index 67a1722..a221137 100644
--- a/scouting/webserver/requests/requests.go
+++ b/scouting/webserver/requests/requests.go
@@ -337,7 +337,31 @@
func parseTeamKey(teamKey string) (int, error) {
// TBA prefixes teams with "frc". Not sure why. Get rid of that.
teamKey = strings.TrimPrefix(teamKey, "frc")
- return strconv.Atoi(teamKey)
+ magnitude := 0
+ if strings.HasSuffix(teamKey, "A") {
+ magnitude = 10000
+ teamKey = strings.TrimSuffix(teamKey, "A")
+ } else if strings.HasSuffix(teamKey, "B") {
+ magnitude = 20000
+ teamKey = strings.TrimSuffix(teamKey, "B")
+ } else if strings.HasSuffix(teamKey, "C") {
+ magnitude = 30000
+ teamKey = strings.TrimSuffix(teamKey, "C")
+ } else if strings.HasSuffix(teamKey, "D") {
+ magnitude = 40000
+ teamKey = strings.TrimSuffix(teamKey, "D")
+ } else if strings.HasSuffix(teamKey, "E") {
+ magnitude = 50000
+ teamKey = strings.TrimSuffix(teamKey, "E")
+ } else if strings.HasSuffix(teamKey, "F") {
+ magnitude = 60000
+ teamKey = strings.TrimSuffix(teamKey, "F")
+ }
+ result, err := strconv.Atoi(teamKey)
+ if err == nil {
+ result += magnitude
+ }
+ return result, err
}
// Parses the alliance data from the specified match and returns the three red