scouting: Convert actions to stats when submitted

Now that actions are submitted, we need to convert them into stats.
This patch does that by calling the correct conversion function and
then inserting the result into the database.

I had to adjust the scouting_test slightly because the behaviour
changed slightly. The test doesn't clear the database between test
cases. So the one test case submitting scout data means it can't be
scouted again. The button is now disabled.

Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: Ib3e68103c8064c61e628711c9fe375919372e18c
diff --git a/scouting/webserver/requests/requests_test.go b/scouting/webserver/requests/requests_test.go
index 5561829..d68dd61 100644
--- a/scouting/webserver/requests/requests_test.go
+++ b/scouting/webserver/requests/requests_test.go
@@ -292,7 +292,6 @@
 		MatchNumber: 3,
 		SetNumber:   1,
 		CompLevel:   "quals",
-		CollectedBy: "katie",
 		ActionsList: []*submit_actions.ActionT{
 			{
 				ActionTaken: &submit_actions.ActionTypeT{
@@ -429,7 +428,7 @@
 		MiddleCones: 0, HighCones: 1, ConesDropped: 0, SuperchargedPieces: 1,
 		AvgCycle: 950, Mobility: true, DockedAuto: true, EngagedAuto: true,
 		BalanceAttemptAuto: false, Docked: true, Engaged: false,
-		BalanceAttempt: true, CollectedBy: "katie",
+		BalanceAttempt: true, CollectedBy: "",
 	}
 
 	if expected != response {
@@ -884,10 +883,28 @@
 		},
 	}
 
+	expectedStats := []db.Stats2023{
+		db.Stats2023{
+			PreScouting: true,
+			TeamNumber:  "1234", MatchNumber: 4, SetNumber: 1,
+			CompLevel: "qual", StartingQuadrant: 0, LowCubesAuto: 0,
+			MiddleCubesAuto: 0, HighCubesAuto: 0, CubesDroppedAuto: 0,
+			LowConesAuto: 0, MiddleConesAuto: 0, HighConesAuto: 0,
+			ConesDroppedAuto: 0, LowCubes: 1, MiddleCubes: 0,
+			HighCubes: 0, CubesDropped: 0, LowCones: 0,
+			MiddleCones: 0, HighCones: 0, ConesDropped: 0, SuperchargedPieces: 0,
+			AvgCycle: 0, Mobility: false, DockedAuto: false, EngagedAuto: false,
+			BalanceAttemptAuto: false, Docked: false, Engaged: false,
+			BalanceAttempt: false, CollectedBy: "debug_cli",
+		},
+	}
+
 	if !reflect.DeepEqual(expectedActions, database.actions) {
 		t.Fatal("Expected ", expectedActions, ", but got:", database.actions)
 	}
-
+	if !reflect.DeepEqual(expectedStats, database.stats2023) {
+		t.Fatal("Expected ", expectedStats, ", but got:", database.stats2023)
+	}
 }
 
 // A mocked database we can use for testing. Add functionality to this as