diff --git a/db/migrations/20140524180123_CreateMatches.sql b/db/migrations/20140524180123_CreateMatches.sql index 0db04b1..03eb24e 100644 --- a/db/migrations/20140524180123_CreateMatches.sql +++ b/db/migrations/20140524180123_CreateMatches.sql @@ -21,6 +21,7 @@ CREATE TABLE matches ( blue3issurrogate bool, status VARCHAR(16), startedat DATETIME, + scorecommittedat DATETIME, winner VARCHAR(16), gamespecificdata VARCHAR(3) ); diff --git a/model/match.go b/model/match.go index b9fede6..603414d 100644 --- a/model/match.go +++ b/model/match.go @@ -33,6 +33,7 @@ type Match struct { Blue3IsSurrogate bool Status string StartedAt time.Time + ScoreCommittedAt time.Time Winner string GameSpecificData string } diff --git a/model/match_test.go b/model/match_test.go index e069caf..7ccaf46 100644 --- a/model/match_test.go +++ b/model/match_test.go @@ -21,7 +21,7 @@ func TestMatchCrud(t *testing.T) { db := setupTestDb(t) match := Match{0, "qualification", "254", time.Now().UTC(), 0, 0, 0, 1, false, 2, false, 3, false, 4, false, - 5, false, 6, false, "", time.Now().UTC(), "", ""} + 5, false, 6, false, "", time.Now().UTC(), time.Now().UTC(), "", ""} db.CreateMatch(&match) match2, err := db.GetMatchById(1) assert.Nil(t, err) @@ -46,7 +46,7 @@ func TestTruncateMatches(t *testing.T) { db := setupTestDb(t) match := Match{0, "qualification", "254", time.Now().UTC(), 0, 0, 0, 1, false, 2, false, 3, false, 4, false, - 5, false, 6, false, "", time.Now().UTC(), "", ""} + 5, false, 6, false, "", time.Now().UTC(), time.Now().UTC(), "", ""} db.CreateMatch(&match) db.TruncateMatches() match2, err := db.GetMatchById(1) @@ -83,13 +83,13 @@ func TestGetMatchesByType(t *testing.T) { db := setupTestDb(t) match := Match{0, "qualification", "1", time.Now().UTC(), 0, 0, 0, 1, false, 2, false, 3, false, 4, false, - 5, false, 6, false, "", time.Now().UTC(), "", ""} + 5, false, 6, false, "", time.Now().UTC(), time.Now().UTC(), "", ""} db.CreateMatch(&match) match2 := Match{0, "practice", "1", time.Now().UTC(), 0, 0, 0, 1, false, 2, false, 3, false, 4, false, 5, - false, 6, false, "", time.Now().UTC(), "", ""} + false, 6, false, "", time.Now().UTC(), time.Now().UTC(), "", ""} db.CreateMatch(&match2) match3 := Match{0, "practice", "2", time.Now().UTC(), 0, 0, 0, 1, false, 2, false, 3, false, 4, false, 5, - false, 6, false, "", time.Now().UTC(), "", ""} + false, 6, false, "", time.Now().UTC(), time.Now().UTC(), "", ""} db.CreateMatch(&match3) matches, err := db.GetMatchesByType("test") diff --git a/web/match_play.go b/web/match_play.go index 6821b83..1b39145 100644 --- a/web/match_play.go +++ b/web/match_play.go @@ -359,6 +359,7 @@ func (web *Web) commitMatchScore(match *model.Match, matchResult *model.MatchRes // Update and save the match record to the database. match.Status = "complete" + match.ScoreCommittedAt = time.Now() redScore := matchResult.RedScoreSummary() blueScore := matchResult.BlueScoreSummary() if redScore.Score > blueScore.Score {