Trying another fix

This commit is contained in:
Asaf Gartner 2022-10-14 06:37:50 +03:00
parent d7f1325ace
commit 09d875a9f6
1 changed files with 8 additions and 2 deletions

View File

@ -774,7 +774,6 @@ func fetchLatestStreamStatus(ctx context.Context, conn db.ConnOrTx, twitchID str
result = &models.TwitchLatestStatus{ result = &models.TwitchLatestStatus{
TwitchID: twitchID, TwitchID: twitchID,
TwitchLogin: twitchLogin, TwitchLogin: twitchLogin,
Tags: make([]string, 0),
} }
} else if err != nil { } else if err != nil {
return nil, oops.New(err, "failed to fetch existing twitch status") return nil, oops.New(err, "failed to fetch existing twitch status")
@ -815,6 +814,10 @@ func saveLatestStreamStatus(ctx context.Context, conn db.ConnOrTx, latest *model
return err return err
} }
if latest.Tags == nil {
latest.Tags = make([]string, 0)
}
_, err = conn.Exec(ctx, _, err = conn.Exec(ctx,
` `
UPDATE twitch_latest_status UPDATE twitch_latest_status
@ -874,7 +877,6 @@ func updateStreamHistory(ctx context.Context, dbConn db.ConnOrTx, status *models
if err == db.NotFound { if err == db.NotFound {
history = &models.TwitchStreamHistory{} history = &models.TwitchStreamHistory{}
history.Tags = make([]string, 0)
history.StreamID = status.StreamID history.StreamID = status.StreamID
history.TwitchID = status.TwitchID history.TwitchID = status.TwitchID
history.TwitchLogin = status.TwitchLogin history.TwitchLogin = status.TwitchLogin
@ -894,6 +896,10 @@ func updateStreamHistory(ctx context.Context, dbConn db.ConnOrTx, status *models
history.CategoryID = status.CategoryID history.CategoryID = status.CategoryID
history.Tags = status.Tags history.Tags = status.Tags
if history.Tags == nil {
history.Tags = make([]string, 0)
}
_, err = tx.Exec(ctx, _, err = tx.Exec(ctx,
` `
INSERT INTO INSERT INTO