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/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)
}
}