Compare commits

..

2 Commits

Author SHA1 Message Date
Asaf Gartner 408e7cb701 Trying some debugging 2022-10-14 07:04:00 +03:00
Asaf Gartner 0b62490a71 Trying another fix 2022-10-14 06:37:50 +03:00
1 changed files with 9 additions and 2 deletions

View File

@ -760,6 +760,7 @@ func fetchLatestStreamStatus(ctx context.Context, conn db.ConnOrTx, twitchID str
twitchID, twitchID,
) )
if err == db.NotFound { if err == db.NotFound {
twitchLog(ctx, conn, models.TwitchLogTypeOther, twitchLogin, "Creating new streamer", fmt.Sprintf("twitchID: %s", twitchID))
_, err = conn.Exec(ctx, _, err = conn.Exec(ctx,
` `
INSERT INTO twitch_latest_status (twitch_id, twitch_login) INSERT INTO twitch_latest_status (twitch_id, twitch_login)
@ -774,7 +775,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 +815,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 +878,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 +897,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