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,
)
if err == db.NotFound {
twitchLog(ctx, conn, models.TwitchLogTypeOther, twitchLogin, "Creating new streamer", fmt.Sprintf("twitchID: %s", twitchID))
_, err = conn.Exec(ctx,
`
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{
TwitchID: twitchID,
TwitchLogin: twitchLogin,
Tags: make([]string, 0),
}
} else if err != nil {
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
}
if latest.Tags == nil {
latest.Tags = make([]string, 0)
}
_, err = conn.Exec(ctx,
`
UPDATE twitch_latest_status
@ -874,7 +878,6 @@ func updateStreamHistory(ctx context.Context, dbConn db.ConnOrTx, status *models
if err == db.NotFound {
history = &models.TwitchStreamHistory{}
history.Tags = make([]string, 0)
history.StreamID = status.StreamID
history.TwitchID = status.TwitchID
history.TwitchLogin = status.TwitchLogin
@ -894,6 +897,10 @@ func updateStreamHistory(ctx context.Context, dbConn db.ConnOrTx, status *models
history.CategoryID = status.CategoryID
history.Tags = status.Tags
if history.Tags == nil {
history.Tags = make([]string, 0)
}
_, err = tx.Exec(ctx,
`
INSERT INTO