From f8466f743a33fb9c02b151168937fe478b460a49 Mon Sep 17 00:00:00 2001 From: Patrick Fairbank Date: Sun, 23 Sep 2018 12:21:32 -0700 Subject: [PATCH] Remove STEMtv client since the service has been discontinued. --- .../20140524160241_CreateEventSettings.sql | 2 - field/arena.go | 2 - model/event_settings.go | 56 +++++++++---------- partner/stemtv.go | 35 ------------ partner/stemtv_test.go | 29 ---------- templates/setup_settings.html | 13 ----- web/match_play.go | 10 ---- web/match_play_test.go | 5 +- web/setup_settings.go | 2 - 9 files changed, 28 insertions(+), 126 deletions(-) delete mode 100644 partner/stemtv.go delete mode 100644 partner/stemtv_test.go diff --git a/db/migrations/20140524160241_CreateEventSettings.sql b/db/migrations/20140524160241_CreateEventSettings.sql index cbfa345..e1000af 100644 --- a/db/migrations/20140524160241_CreateEventSettings.sql +++ b/db/migrations/20140524160241_CreateEventSettings.sql @@ -23,8 +23,6 @@ CREATE TABLE event_settings ( tbadownloadenabled bool, adminpassword VARCHAR(255), readerpassword VARCHAR(255), - stemtvpublishingenabled bool, - stemtveventcode VARCHAR(16), scaleledaddress VARCHAR(255), redswitchledaddress VARCHAR(255), blueswitchledaddress VARCHAR(255), diff --git a/field/arena.go b/field/arena.go index 3c7f468..451c305 100644 --- a/field/arena.go +++ b/field/arena.go @@ -48,7 +48,6 @@ type Arena struct { networkSwitch *NetworkSwitch Plc plc.Plc TbaClient *partner.TbaClient - StemTvClient *partner.StemTvClient AllianceStations map[string]*AllianceStation Displays map[string]*Display ArenaNotifiers @@ -148,7 +147,6 @@ func (arena *Arena) LoadSettings() error { arena.networkSwitch = NewNetworkSwitch(settings.SwitchAddress, settings.SwitchPassword) arena.Plc.SetAddress(settings.PlcAddress) arena.TbaClient = partner.NewTbaClient(settings.TbaEventCode, settings.TbaSecretId, settings.TbaSecret) - arena.StemTvClient = partner.NewStemTvClient(settings.StemTvEventCode) if arena.EventSettings.NetworkSecurityEnabled { if err = arena.accessPoint.ConfigureAdminWifi(); err != nil { diff --git a/model/event_settings.go b/model/event_settings.go index bea7525..068282b 100644 --- a/model/event_settings.go +++ b/model/event_settings.go @@ -6,35 +6,33 @@ package model type EventSettings struct { - Id int - Name string - NumElimAlliances int - SelectionRound2Order string - SelectionRound3Order string - TBADownloadEnabled bool - TbaPublishingEnabled bool - TbaEventCode string - TbaSecretId string - TbaSecret string - NetworkSecurityEnabled bool - ApAddress string - ApUsername string - ApPassword string - ApTeamChannel int - ApAdminChannel int - ApAdminWpaKey string - SwitchAddress string - SwitchPassword string - PlcAddress string - AdminPassword string - ReaderPassword string - StemTvPublishingEnabled bool - StemTvEventCode string - ScaleLedAddress string - RedSwitchLedAddress string - BlueSwitchLedAddress string - RedVaultLedAddress string - BlueVaultLedAddress string + Id int + Name string + NumElimAlliances int + SelectionRound2Order string + SelectionRound3Order string + TBADownloadEnabled bool + TbaPublishingEnabled bool + TbaEventCode string + TbaSecretId string + TbaSecret string + NetworkSecurityEnabled bool + ApAddress string + ApUsername string + ApPassword string + ApTeamChannel int + ApAdminChannel int + ApAdminWpaKey string + SwitchAddress string + SwitchPassword string + PlcAddress string + AdminPassword string + ReaderPassword string + ScaleLedAddress string + RedSwitchLedAddress string + BlueSwitchLedAddress string + RedVaultLedAddress string + BlueVaultLedAddress string } const eventSettingsId = 0 diff --git a/partner/stemtv.go b/partner/stemtv.go deleted file mode 100644 index 6884f8d..0000000 --- a/partner/stemtv.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2016 Team 254. All Rights Reserved. -// Author: pat@patfairbank.com (Patrick Fairbank) -// -// Methods for publishing match video split information to STEMtv. - -package partner - -import ( - "fmt" - "github.com/Team254/cheesy-arena/model" - "net/http" - "time" -) - -type StemTvClient struct { - BaseUrl string - eventCode string -} - -const ( - stemTvBaseUrl = "http://52.21.72.74:5000" - preMatchPaddingSec = 5 - postScoreDisplayPaddingSec = 10 -) - -func NewStemTvClient(eventCode string) *StemTvClient { - return &StemTvClient{stemTvBaseUrl, eventCode} -} - -func (client *StemTvClient) PublishMatchVideoSplit(match *model.Match, scoreDisplayTime time.Time) error { - url := fmt.Sprintf("%s/event/api/v1.0/%s/%s/split/%d,%d", client.BaseUrl, client.eventCode, match.TbaCode(), - match.StartedAt.Unix()-preMatchPaddingSec, scoreDisplayTime.Unix()+postScoreDisplayPaddingSec) - _, err := http.Get(url) - return err -} diff --git a/partner/stemtv_test.go b/partner/stemtv_test.go deleted file mode 100644 index f7e4320..0000000 --- a/partner/stemtv_test.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2016 Team 254. All Rights Reserved. -// Author: pat@patfairbank.com (Patrick Fairbank) - -package partner - -import ( - "github.com/Team254/cheesy-arena/model" - "github.com/stretchr/testify/assert" - "net/http" - "net/http/httptest" - "testing" - "time" -) - -func TestPublishMatchVideoSplit(t *testing.T) { - // Mock the STEMtv server. - stemTvServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - assert.Equal(t, "/event/api/v1.0/my_event_code/qm254/split/981187501,981187690", r.URL.String()) - })) - defer stemTvServer.Close() - - client := NewStemTvClient("my_event_code") - client.BaseUrl = stemTvServer.URL - - matchStartedTime, _ := time.Parse("2006-01-02 15:04:05 -0700", "2001-02-03 04:05:06 -0400") - match := &model.Match{Type: "qualification", DisplayName: "254", StartedAt: matchStartedTime} - scoreDisplayTime, _ := time.Parse("2006-01-02 15:04:05 -0700", "2001-02-03 04:08:00 -0400") - assert.Nil(t, client.PublishMatchVideoSplit(match, scoreDisplayTime)) -} diff --git a/templates/setup_settings.html b/templates/setup_settings.html index 918f4ec..46c4b0e 100644 --- a/templates/setup_settings.html +++ b/templates/setup_settings.html @@ -112,19 +112,6 @@ -

Contact STEMtv to obtain an event code.

-
- -
- -
-
-
- -
- -
-
Authentication diff --git a/web/match_play.go b/web/match_play.go index a3aa470..6821b83 100644 --- a/web/match_play.go +++ b/web/match_play.go @@ -410,16 +410,6 @@ func (web *Web) commitMatchScore(match *model.Match, matchResult *model.MatchRes }() } - if web.arena.EventSettings.StemTvPublishingEnabled && match.Type != "practice" { - // Publish asynchronously to STEMtv. - go func() { - err = web.arena.StemTvClient.PublishMatchVideoSplit(match, time.Now()) - if err != nil { - log.Printf("Failed to publish match video split to STEMtv: %s", err.Error()) - } - }() - } - // Back up the database, but don't error out if it fails. err = web.arena.Database.Backup(web.arena.EventSettings.Name, fmt.Sprintf("post_%s_match_%s", match.Type, match.DisplayName)) if err != nil { diff --git a/web/match_play_test.go b/web/match_play_test.go index 18be8f6..b5d3e1d 100644 --- a/web/match_play_test.go +++ b/web/match_play_test.go @@ -157,11 +157,9 @@ func TestCommitMatch(t *testing.T) { match, _ = web.arena.Database.GetMatchById(1) assert.Equal(t, "T", match.Winner) - // Verify TBA and STEMtv publishing by checking the log for the expected failure messages. + // Verify TBA publishing by checking the log for the expected failure messages. web.arena.TbaClient.BaseUrl = "fakeUrl" - web.arena.StemTvClient.BaseUrl = "fakeUrl" web.arena.EventSettings.TbaPublishingEnabled = true - web.arena.EventSettings.StemTvPublishingEnabled = true var writer bytes.Buffer log.SetOutput(&writer) err = web.commitMatchScore(match, matchResult, false) @@ -169,7 +167,6 @@ func TestCommitMatch(t *testing.T) { time.Sleep(time.Millisecond * 10) // Allow some time for the asynchronous publishing to happen. assert.Contains(t, writer.String(), "Failed to publish matches") assert.Contains(t, writer.String(), "Failed to publish rankings") - assert.Contains(t, writer.String(), "Failed to publish match video split to STEMtv") } func TestCommitEliminationTie(t *testing.T) { diff --git a/web/setup_settings.go b/web/setup_settings.go index a5c2cf6..5bb63dc 100644 --- a/web/setup_settings.go +++ b/web/setup_settings.go @@ -48,8 +48,6 @@ func (web *Web) settingsPostHandler(w http.ResponseWriter, r *http.Request) { eventSettings.TbaEventCode = r.PostFormValue("tbaEventCode") eventSettings.TbaSecretId = r.PostFormValue("tbaSecretId") eventSettings.TbaSecret = r.PostFormValue("tbaSecret") - eventSettings.StemTvPublishingEnabled = r.PostFormValue("stemTvPublishingEnabled") == "on" - eventSettings.StemTvEventCode = r.PostFormValue("stemTvEventCode") eventSettings.NetworkSecurityEnabled = r.PostFormValue("networkSecurityEnabled") == "on" eventSettings.ApAddress = r.PostFormValue("apAddress") eventSettings.ApUsername = r.PostFormValue("apUsername")