From fa9c913b53fe10cba824d193d365207c1f3a1f3d Mon Sep 17 00:00:00 2001 From: Alessio Date: Sun, 5 Nov 2023 14:45:25 -0400 Subject: [PATCH] Fix spaces with no created_by_id crashing the app --- pkg/persistence/compound_queries.go | 4 ++-- pkg/persistence/space_queries.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/persistence/compound_queries.go b/pkg/persistence/compound_queries.go index 0f23ed0..6765554 100644 --- a/pkg/persistence/compound_queries.go +++ b/pkg/persistence/compound_queries.go @@ -59,8 +59,8 @@ func (p Profile) fill_content(trove *TweetTrove, current_user_id UserID) { if len(space_ids) > 0 { var spaces []Space err := p.DB.Select(&spaces, ` - select id, created_by_id, short_url, state, title, created_at, started_at, ended_at, updated_at, is_available_for_replay, - replay_watch_count, live_listeners_count, is_details_fetched + select id, ifnull(created_by_id, 0) created_by_id, short_url, state, title, created_at, started_at, ended_at, updated_at, + is_available_for_replay, replay_watch_count, live_listeners_count, is_details_fetched from spaces where id in (`+strings.Repeat("?,", len(space_ids)-1)+`?)`, space_ids..., diff --git a/pkg/persistence/space_queries.go b/pkg/persistence/space_queries.go index c7d597b..48dbb0d 100644 --- a/pkg/persistence/space_queries.go +++ b/pkg/persistence/space_queries.go @@ -54,8 +54,8 @@ func (p Profile) SaveSpace(s scraper.Space) error { // Get a Space by ID func (p Profile) GetSpaceById(id scraper.SpaceID) (space scraper.Space, err error) { err = p.DB.Get(&space, - `select id, created_by_id, short_url, state, title, created_at, started_at, ended_at, updated_at, is_available_for_replay, - replay_watch_count, live_listeners_count, is_details_fetched + `select id, ifnull(created_by_id, 0) created_by_id, short_url, state, title, created_at, started_at, ended_at, updated_at, + is_available_for_replay, replay_watch_count, live_listeners_count, is_details_fetched from spaces where id = ?`, id) if err != nil {