scouting: Add support /requests/request/all_matches

This patch adds a new endpoint that accepts the `RequestAllMatches`
message. It simply returns the full list of matches that the database
knows about.

I decided to change public `int` members in the `db` module to `int32`
so they match the flatbuffer definition. This makes comparison
simpler.

Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: I9bb2eed020e2889644f5a122105a232a68f2f4bd
diff --git a/scouting/webserver/requests/debug/BUILD b/scouting/webserver/requests/debug/BUILD
index cfeee2f..189296d 100644
--- a/scouting/webserver/requests/debug/BUILD
+++ b/scouting/webserver/requests/debug/BUILD
@@ -8,6 +8,7 @@
     visibility = ["//visibility:public"],
     deps = [
         "//scouting/webserver/requests/messages:error_response_go_fbs",
+        "//scouting/webserver/requests/messages:request_all_matches_response_go_fbs",
         "//scouting/webserver/requests/messages:submit_data_scouting_response_go_fbs",
     ],
 )
diff --git a/scouting/webserver/requests/debug/cli/cli_test.py b/scouting/webserver/requests/debug/cli/cli_test.py
index 87c22c0..8020c64 100644
--- a/scouting/webserver/requests/debug/cli/cli_test.py
+++ b/scouting/webserver/requests/debug/cli/cli_test.py
@@ -1,3 +1,5 @@
+# TODO(phil): Rewrite this in Go.
+
 import json
 import os
 from pathlib import Path
@@ -67,5 +69,14 @@
         self.assertEqual(exit_code, 1)
         self.assertIn("/requests/submit/data_scouting returned 501 Not Implemented", stderr)
 
+    def test_request_all_matches(self):
+        # RequestAllMatches has no fields.
+        json_path = write_json({})
+        exit_code, _stdout, stderr = run_debug_cli(["-requestAllMatches", json_path])
+
+        # TODO(phil): Actually add some matches here.
+        self.assertEqual(exit_code, 0)
+        self.assertIn("{MatchList:[]}", stderr)
+
 if __name__ == "__main__":
     unittest.main()
diff --git a/scouting/webserver/requests/debug/cli/main.go b/scouting/webserver/requests/debug/cli/main.go
index ac24b25..204e541 100644
--- a/scouting/webserver/requests/debug/cli/main.go
+++ b/scouting/webserver/requests/debug/cli/main.go
@@ -50,9 +50,9 @@
 	// Execute the `flatc` command.
 	flatcCommand := exec.Command(absFlatcPath, "--binary", absFbsPath, jsonSymlink)
 	flatcCommand.Dir = dir
-	err = flatcCommand.Run()
+	output, err := flatcCommand.CombinedOutput()
 	if err != nil {
-		log.Fatal("Failed to execute flatc: ", err)
+		log.Fatal("Failed to execute flatc: ", err, ": ", string(output))
 	}
 
 	// Read the serialized flatbuffer and return it.
@@ -70,6 +70,8 @@
 		"The end point where the server is listening.")
 	submitDataScoutingPtr := flag.String("submitDataScouting", "",
 		"If specified, parse the file as a SubmitDataScouting JSON request.")
+	requestAllMatchesPtr := flag.String("requestAllMatches", "",
+		"If specified, parse the file as a RequestAllMatches JSON request.")
 	flag.Parse()
 
 	// Handle the actual arguments.
@@ -82,6 +84,17 @@
 		if err != nil {
 			log.Fatal("Failed SubmitDataScouting: ", err)
 		}
-		log.Printf("%+v", response)
+		log.Printf("%+v", *response)
+	}
+	if *requestAllMatchesPtr != "" {
+		log.Printf("Sending RequestAllMatches to %s", *addressPtr)
+		binaryRequest := parseJson(
+			"scouting/webserver/requests/messages/request_all_matches.fbs",
+			*requestAllMatchesPtr)
+		response, err := debug.RequestAllMatches(*addressPtr, binaryRequest)
+		if err != nil {
+			log.Fatal("Failed RequestAllMatches: ", err)
+		}
+		log.Printf("%+v", *response)
 	}
 }
diff --git a/scouting/webserver/requests/debug/debug.go b/scouting/webserver/requests/debug/debug.go
index dd70c1b..5984c7a 100644
--- a/scouting/webserver/requests/debug/debug.go
+++ b/scouting/webserver/requests/debug/debug.go
@@ -9,11 +9,13 @@
 	"net/http"
 
 	"github.com/frc971/971-Robot-Code/scouting/webserver/requests/messages/error_response"
+	"github.com/frc971/971-Robot-Code/scouting/webserver/requests/messages/request_all_matches_response"
 	"github.com/frc971/971-Robot-Code/scouting/webserver/requests/messages/submit_data_scouting_response"
 )
 
 // Use aliases to make the rest of the code more readable.
 type SubmitDataScoutingResponseT = submit_data_scouting_response.SubmitDataScoutingResponseT
+type RequestAllMatchesResponseT = request_all_matches_response.RequestAllMatchesResponseT
 
 // A struct that can be used as an `error`. It contains information about the
 // why the server was unhappy and what the corresponding request was.
@@ -85,3 +87,15 @@
 	response := submit_data_scouting_response.GetRootAsSubmitDataScoutingResponse(responseBytes, 0)
 	return response.UnPack(), nil
 }
+
+// Sends a `RequestAllMatches` message to the server and returns the
+// deserialized response.
+func RequestAllMatches(server string, requestBytes []byte) (*RequestAllMatchesResponseT, error) {
+	responseBytes, err := performPost(server+"/requests/request/all_matches", requestBytes)
+	if err != nil {
+		return nil, err
+	}
+	log.Printf("Parsing RequestAllMatchesResponse")
+	response := request_all_matches_response.GetRootAsRequestAllMatchesResponse(responseBytes, 0)
+	return response.UnPack(), nil
+}