Scouting App: Add View data webserver

Add methods to return all Notes, Stats, and Driver Rankings.

Signed-off-by: Filip Kujawa <filip.j.kujawa@gmail.com>
Change-Id: I0cc8531c9aa34e8dbccf08cada9957272537024f
diff --git a/scouting/webserver/requests/debug/cli/cli_test.py b/scouting/webserver/requests/debug/cli/cli_test.py
index d4310e9..5cfeb61 100644
--- a/scouting/webserver/requests/debug/cli/cli_test.py
+++ b/scouting/webserver/requests/debug/cli/cli_test.py
@@ -141,6 +141,73 @@
             CompLevel: (string) (len=5) "quals"
             }"""), stdout)
 
+    def test_submit_and_request_notes(self):
+        self.refresh_match_list(year=2020, event_code="fake")
+
+        # First submit some data to be added to the database.
+        json_path = write_json_request({
+            "team": 100,
+            "notes": "A very inspiring and useful comment",
+            "good_driving": True,
+            "bad_driving": False,
+            "sketchy_climb": False,
+            "solid_climb": True,
+            "good_defense": False,
+            "bad_defense": False,
+        })
+        exit_code, _, stderr = run_debug_cli(["-submitNotes", json_path])
+        self.assertEqual(exit_code, 0, stderr)
+
+        # Now request the data back with zero indentation. That let's us
+        # validate the data easily.
+        json_path = write_json_request({})
+        exit_code, stdout, stderr = run_debug_cli(
+            ["-requestAllNotes", json_path, "-indent="])
+
+        self.assertEqual(exit_code, 0, stderr)
+        self.assertIn(
+            textwrap.dedent("""\
+            {
+            Team: (int32) 100,
+            Notes: (string) (len=35) "A very inspiring and useful comment",
+            GoodDriving: (bool) true,
+            BadDriving: (bool) false,
+            SketchyClimb: (bool) false,
+            SolidClimb: (bool) true,
+            GoodDefense: (bool) false,
+            BadDefense: (bool) false
+            }"""), stdout)
+
+    def test_submit_and_request_driver_ranking(self):
+        self.refresh_match_list(year=2020, event_code="fake")
+
+        # First submit some data to be added to the database.
+        json_path = write_json_request({
+            "matchNumber": 100,
+            "rank1": 101,
+            "rank2": 202,
+            "rank3": 303,
+        })
+        exit_code, _, stderr = run_debug_cli(
+            ["-submitDriverRanking", json_path])
+        self.assertEqual(exit_code, 0, stderr)
+
+        # Now request the data back with zero indentation. That let's us
+        # validate the data easily.
+        json_path = write_json_request({})
+        exit_code, stdout, stderr = run_debug_cli(
+            ["-requestAllDriverRankings", json_path, "-indent="])
+
+        self.assertEqual(exit_code, 0, stderr)
+        self.assertIn(
+            textwrap.dedent("""\
+            {
+            MatchNumber: (int32) 100,
+            Rank1: (int32) 101,
+            Rank2: (int32) 202,
+            Rank3: (int32) 303
+            }"""), stdout)
+
     def test_request_all_matches(self):
         self.refresh_match_list()
 
diff --git a/scouting/webserver/requests/debug/cli/main.go b/scouting/webserver/requests/debug/cli/main.go
index d338b5f..ec38270 100644
--- a/scouting/webserver/requests/debug/cli/main.go
+++ b/scouting/webserver/requests/debug/cli/main.go
@@ -85,12 +85,20 @@
 		"The end point where the server is listening.")
 	submitDataScoutingPtr := flag.String("submitDataScouting", "",
 		"If specified, parse the file as a SubmitDataScouting JSON request.")
+	submitDriverRankingPtr := flag.String("submitDriverRanking", "",
+		"If specified, parse the file as a submitDriverRanking JSON request.")
+	submitNotesPtr := flag.String("submitNotes", "",
+		"If specified, parse the file as a submitNotes JSON request.")
 	requestAllMatchesPtr := flag.String("requestAllMatches", "",
 		"If specified, parse the file as a RequestAllMatches JSON request.")
 	requestMatchesForTeamPtr := flag.String("requestMatchesForTeam", "",
 		"If specified, parse the file as a RequestMatchesForTeam JSON request.")
 	requestDataScoutingPtr := flag.String("requestDataScouting", "",
 		"If specified, parse the file as a RequestDataScouting JSON request.")
+	requestAllDriverRankingsPtr := flag.String("requestAllDriverRankings", "",
+		"If specified, parse the file as a requestAllDriverRankings JSON request.")
+	requestAllNotesPtr := flag.String("requestAllNotes", "",
+		"If specified, parse the file as a requestAllNotes JSON request.")
 	refreshMatchListPtr := flag.String("refreshMatchList", "",
 		"If specified, parse the file as a RefreshMatchList JSON request.")
 	flag.Parse()
@@ -109,6 +117,20 @@
 		debug.SubmitDataScouting)
 
 	maybePerformRequest(
+		"submitNotes",
+		"scouting/webserver/requests/messages/submit_notes.fbs",
+		*submitNotesPtr,
+		*addressPtr,
+		debug.SubmitNotes)
+
+	maybePerformRequest(
+		"submitDriverRanking",
+		"scouting/webserver/requests/messages/submit_driver_ranking.fbs",
+		*submitDriverRankingPtr,
+		*addressPtr,
+		debug.SubmitDriverRanking)
+
+	maybePerformRequest(
 		"RequestAllMatches",
 		"scouting/webserver/requests/messages/request_all_matches.fbs",
 		*requestAllMatchesPtr,
@@ -130,6 +152,20 @@
 		debug.RequestDataScouting)
 
 	maybePerformRequest(
+		"requestAllDriverRankings",
+		"scouting/webserver/requests/messages/request_all_driver_rankings.fbs",
+		*requestAllDriverRankingsPtr,
+		*addressPtr,
+		debug.RequestAllDriverRankings)
+
+	maybePerformRequest(
+		"requestAllNotes",
+		"scouting/webserver/requests/messages/request_all_notes.fbs",
+		*requestAllNotesPtr,
+		*addressPtr,
+		debug.RequestAllNotes)
+
+	maybePerformRequest(
 		"RefreshMatchList",
 		"scouting/webserver/requests/messages/refresh_match_list.fbs",
 		*refreshMatchListPtr,