Skip to content

Commit f6476be

Browse files
committed
Revert "Move TBA match publishing from time of commit to time of showing score. Closes Team254#16."
Idk if this is why it isn't working, but maybe it might help. This reverts commit 3cd216c.
1 parent b587d0a commit f6476be

File tree

2 files changed

+27
-40
lines changed

2 files changed

+27
-40
lines changed

match_play.go

+16-26
Original file line numberDiff line numberDiff line change
@@ -154,32 +154,6 @@ func MatchPlayShowResultHandler(w http.ResponseWriter, r *http.Request) {
154154
mainArena.savedMatchResult = matchResult
155155
mainArena.scorePostedNotifier.Notify(nil)
156156

157-
if eventSettings.TbaPublishingEnabled && match.Type != "practice" {
158-
// Publish asynchronously to The Blue Alliance.
159-
go func() {
160-
err = PublishMatches()
161-
if err != nil {
162-
log.Printf("Failed to publish matches: %s", err.Error())
163-
}
164-
if match.Type == "qualification" {
165-
err = PublishRankings()
166-
if err != nil {
167-
log.Printf("Failed to publish rankings: %s", err.Error())
168-
}
169-
}
170-
}()
171-
}
172-
173-
if eventSettings.StemTvPublishingEnabled && match.Type != "practice" {
174-
// Publish asynchronously to STEMtv.
175-
go func() {
176-
err = PublishMatchVideoSplit(match, time.Now())
177-
if err != nil {
178-
log.Printf("Failed to publish match video split to STEMtv: %s", err.Error())
179-
}
180-
}()
181-
}
182-
183157
http.Redirect(w, r, "/match_play", 302)
184158
}
185159

@@ -531,6 +505,22 @@ func CommitMatchScore(match *Match, matchResult *MatchResult, loadToShowBuffer b
531505
}
532506
}
533507

508+
if eventSettings.TbaPublishingEnabled && match.Type != "practice" {
509+
// Publish asynchronously to The Blue Alliance.
510+
go func() {
511+
err = PublishMatches()
512+
if err != nil {
513+
log.Printf("Failed to publish matches: %s", err.Error())
514+
}
515+
if match.Type == "qualification" {
516+
err = PublishRankings()
517+
if err != nil {
518+
log.Printf("Failed to publish rankings: %s", err.Error())
519+
}
520+
}
521+
}()
522+
}
523+
534524
// Back up the database, but don't error out if it fails.
535525
err = db.Backup(fmt.Sprintf("post_%s_match_%s", match.Type, match.DisplayName))
536526
if err != nil {

match_play_test.go

+11-14
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,6 @@ func TestMatchPlayShowResult(t *testing.T) {
121121
assert.Equal(t, 302, recorder.Code)
122122
assert.Equal(t, match.Id, mainArena.savedMatch.Id)
123123
assert.Equal(t, match.Id, mainArena.savedMatchResult.MatchId)
124-
125-
// Verify TBA and STEMtv publishing by checking the log for the expected failure messages.
126-
tbaBaseUrl = "fakeurl"
127-
stemTvBaseUrl = "fakeurl"
128-
eventSettings.TbaPublishingEnabled = true
129-
eventSettings.StemTvPublishingEnabled = true
130-
var writer bytes.Buffer
131-
log.SetOutput(&writer)
132-
recorder = getHttpResponse(fmt.Sprintf("/match_play/%d/show_result", match.Id))
133-
assert.Equal(t, 302, recorder.Code)
134-
time.Sleep(time.Millisecond * 10) // Allow some time for the asynchronous publishing to happen.
135-
assert.Contains(t, writer.String(), "Failed to publish matches")
136-
assert.Contains(t, writer.String(), "Failed to publish rankings")
137-
assert.Contains(t, writer.String(), "Failed to publish match video split to STEMtv")
138124
}
139125

140126
func TestMatchPlayErrors(t *testing.T) {
@@ -192,6 +178,17 @@ func TestCommitMatch(t *testing.T) {
192178
assert.Equal(t, 3, matchResult.PlayNumber)
193179
match, _ = db.GetMatchById(1)
194180
assert.Equal(t, "T", match.Winner)
181+
182+
// Verify TBA publishing by checking the log for the expected failure messages.
183+
tbaBaseUrl = "fakeurl"
184+
eventSettings.TbaPublishingEnabled = true
185+
var writer bytes.Buffer
186+
log.SetOutput(&writer)
187+
err = CommitMatchScore(match, matchResult, false)
188+
assert.Nil(t, err)
189+
time.Sleep(time.Millisecond * 10) // Allow some time for the asynchronous publishing to happen.
190+
assert.Contains(t, writer.String(), "Failed to publish matches")
191+
assert.Contains(t, writer.String(), "Failed to publish rankings")
195192
}
196193

197194
func TestCommitEliminationTie(t *testing.T) {

0 commit comments

Comments
 (0)