Fix spaces with no created_by_id crashing the app

This commit is contained in:
Alessio 2023-11-05 14:45:25 -04:00
parent 2b5db51fc1
commit fa9c913b53
2 changed files with 4 additions and 4 deletions

View File

@ -59,8 +59,8 @@ func (p Profile) fill_content(trove *TweetTrove, current_user_id UserID) {
if len(space_ids) > 0 { if len(space_ids) > 0 {
var spaces []Space var spaces []Space
err := p.DB.Select(&spaces, ` 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, select id, ifnull(created_by_id, 0) created_by_id, short_url, state, title, created_at, started_at, ended_at, updated_at,
replay_watch_count, live_listeners_count, is_details_fetched is_available_for_replay, replay_watch_count, live_listeners_count, is_details_fetched
from spaces from spaces
where id in (`+strings.Repeat("?,", len(space_ids)-1)+`?)`, where id in (`+strings.Repeat("?,", len(space_ids)-1)+`?)`,
space_ids..., space_ids...,

View File

@ -54,8 +54,8 @@ func (p Profile) SaveSpace(s scraper.Space) error {
// Get a Space by ID // Get a Space by ID
func (p Profile) GetSpaceById(id scraper.SpaceID) (space scraper.Space, err error) { func (p Profile) GetSpaceById(id scraper.SpaceID) (space scraper.Space, err error) {
err = p.DB.Get(&space, 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, `select id, ifnull(created_by_id, 0) created_by_id, short_url, state, title, created_at, started_at, ended_at, updated_at,
replay_watch_count, live_listeners_count, is_details_fetched is_available_for_replay, replay_watch_count, live_listeners_count, is_details_fetched
from spaces from spaces
where id = ?`, id) where id = ?`, id)
if err != nil { if err != nil {