scouting: Fix timestamp issue during action submission
The newly deployed scouting app was giving users these kinds of
errors:
Received 500 Internal Server Error: "Failed to add action to
database: ERROR: null value in column "time_stamp" of relation
"actions" violates not-null constraint (SQLSTATE 23502)"
The issue was that the database was created with the
`Action.TimeStamp` field. This was the spelling from the action
submission patch I cherry-picked a long time ago. Later, as the action
submission patch made its way onto master, the spelling changed to
`Action.Timestamp`. This means that a database that was already
created cannot be used by both versions of the software.
Since the database already used the `TimeStamp` spelling, I am
changing the code here to match. For next year, we should settle on a
spelling and fix it.
Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: I776724e740556ff8267d7a68be5111793b4574db
diff --git a/scouting/db/db.go b/scouting/db/db.go
index 1282638..b4d1bca 100644
--- a/scouting/db/db.go
+++ b/scouting/db/db.go
@@ -62,8 +62,9 @@
CompLevel string `gorm:"primaryKey"`
// This contains a serialized scouting.webserver.requests.ActionType flatbuffer.
CompletedAction []byte
- Timestamp int64 `gorm:"primaryKey"`
- CollectedBy string
+ // TODO(phil): Get all the spellings of "timestamp" to be the same.
+ TimeStamp int64 `gorm:"primaryKey"`
+ CollectedBy string
}
type NotesData struct {
diff --git a/scouting/db/db_test.go b/scouting/db/db_test.go
index 663a080..bef396b 100644
--- a/scouting/db/db_test.go
+++ b/scouting/db/db_test.go
@@ -813,27 +813,27 @@
correct := []Action{
Action{
TeamNumber: "1235", MatchNumber: 94, SetNumber: 1, CompLevel: "quals",
- CompletedAction: []byte(""), Timestamp: 0000, CollectedBy: "",
+ CompletedAction: []byte(""), TimeStamp: 0000, CollectedBy: "",
},
Action{
TeamNumber: "1236", MatchNumber: 94, SetNumber: 1, CompLevel: "quals",
- CompletedAction: []byte(""), Timestamp: 0321, CollectedBy: "",
+ CompletedAction: []byte(""), TimeStamp: 0321, CollectedBy: "",
},
Action{
TeamNumber: "1237", MatchNumber: 94, SetNumber: 1, CompLevel: "quals",
- CompletedAction: []byte(""), Timestamp: 0222, CollectedBy: "",
+ CompletedAction: []byte(""), TimeStamp: 0222, CollectedBy: "",
},
Action{
TeamNumber: "1238", MatchNumber: 94, SetNumber: 1, CompLevel: "quals",
- CompletedAction: []byte(""), Timestamp: 0110, CollectedBy: "",
+ CompletedAction: []byte(""), TimeStamp: 0110, CollectedBy: "",
},
Action{
TeamNumber: "1239", MatchNumber: 94, SetNumber: 1, CompLevel: "quals",
- CompletedAction: []byte(""), Timestamp: 0004, CollectedBy: "",
+ CompletedAction: []byte(""), TimeStamp: 0004, CollectedBy: "",
},
Action{
TeamNumber: "1233", MatchNumber: 94, SetNumber: 1, CompLevel: "quals",
- CompletedAction: []byte(""), Timestamp: 0005, CollectedBy: "",
+ CompletedAction: []byte(""), TimeStamp: 0005, CollectedBy: "",
},
}
diff --git a/scouting/webserver/requests/requests.go b/scouting/webserver/requests/requests.go
index 8293fa2..e5b4680 100644
--- a/scouting/webserver/requests/requests.go
+++ b/scouting/webserver/requests/requests.go
@@ -834,7 +834,7 @@
CompLevel: string(request.CompLevel()),
//TODO: Serialize CompletedAction
CompletedAction: []byte{},
- Timestamp: action.Timestamp(),
+ TimeStamp: action.Timestamp(),
CollectedBy: username,
}
diff --git a/scouting/webserver/requests/requests_test.go b/scouting/webserver/requests/requests_test.go
index d68dd61..9a07726 100644
--- a/scouting/webserver/requests/requests_test.go
+++ b/scouting/webserver/requests/requests_test.go
@@ -869,7 +869,7 @@
CompLevel: "qual",
CollectedBy: "debug_cli",
CompletedAction: []byte{},
- Timestamp: 2400,
+ TimeStamp: 2400,
},
{
PreScouting: true,
@@ -879,7 +879,7 @@
CompLevel: "qual",
CollectedBy: "debug_cli",
CompletedAction: []byte{},
- Timestamp: 1009,
+ TimeStamp: 1009,
},
}