Skip to content

Commit 5cc784f

Browse files
committed
fix: error on opening profile page
1 parent 8a74149 commit 5cc784f

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

backend/routers/lists.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ async def create_list(
153153
"item_count": 0,
154154
"created_at": lst.created_at.isoformat(),
155155
"updated_at": lst.updated_at.isoformat(),
156+
"preview_posters": [],
156157
}
157158

158159

backend/routers/profile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ async def get_public_profile(
567567
list_ids = [row.id for row in lists_rows]
568568

569569
# Fetch up to 3 preview posters per list using ROW_NUMBER
570-
posters_by_list: dict[int, list[str]] = {}
570+
posters_by_list: dict[int, list[dict]] = {}
571571
if list_ids:
572572
ShowAlias = aliased(ShowModel)
573573
rn = func.row_number().over(
@@ -579,18 +579,18 @@ async def get_public_profile(
579579
else_=ShowAlias.poster_path,
580580
).label("poster")
581581
inner = (
582-
select(ListItem.list_id, poster_col, rn)
582+
select(ListItem.list_id, poster_col, Media.adult, rn)
583583
.join(Media, ListItem.media_id == Media.id)
584584
.outerjoin(ShowAlias, ShowAlias.tmdb_id == Media.tmdb_id)
585585
.where(ListItem.list_id.in_(list_ids))
586586
).subquery()
587587
posters_q = await db.execute(
588-
select(inner.c.list_id, inner.c.poster)
588+
select(inner.c.list_id, inner.c.poster, inner.c.adult)
589589
.where(inner.c.rn <= 3)
590590
.where(inner.c.poster.isnot(None))
591591
)
592592
for row in posters_q.all():
593-
posters_by_list.setdefault(row.list_id, []).append(row.poster)
593+
posters_by_list.setdefault(row.list_id, []).append({"url": row.poster, "adult": row.adult})
594594

595595
user_lists = [
596596
{

frontend/src/components/ListCard.astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ interface Props {
1111
username?: string; // for public/community lists
1212
}
1313
14-
const { id, name, description, privacy_level, item_count, preview_posters, username } = Astro.props;
14+
const { id, name, description, privacy_level, item_count, preview_posters = [], username } = Astro.props;
1515
1616
function posterSrc(path: string): string {
17+
if (!path) return "";
18+
if (typeof path !== "string") return "";
1719
if (path.startsWith("http")) return path;
1820
return `https://image.tmdb.org/t/p/w185${path}`;
1921
}

0 commit comments

Comments
 (0)