From 5780493623ec8d78f2acffdc303a4a7a7ed5b617 Mon Sep 17 00:00:00 2001 From: Stefan Hardegger Date: Fri, 27 Mar 2026 14:30:30 +0100 Subject: [PATCH] Fixing author page load times --- frontend/src/app/authors/[id]/page.tsx | 10 +++------- frontend/src/lib/api.ts | 5 +++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/authors/[id]/page.tsx b/frontend/src/app/authors/[id]/page.tsx index 090d909..60e0c93 100644 --- a/frontend/src/app/authors/[id]/page.tsx +++ b/frontend/src/app/authors/[id]/page.tsx @@ -26,15 +26,11 @@ export default function AuthorDetailPage() { setLoading(true); const [authorData, storiesResult] = await Promise.all([ authorApi.getAuthor(authorId), - storyApi.getStories({ page: 0, size: 1000 }) // Get all stories to filter by author + storyApi.getStoriesByAuthor(authorId, { page: 0, size: 100 }) ]); - + setAuthor(authorData); - // Filter stories by this author - const authorStories = storiesResult.content.filter( - story => story.authorId === authorId - ); - setStories(authorStories); + setStories(storiesResult.content); } catch (error) { console.error('Failed to load author data:', error); router.push('/authors'); diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index 26e01f3..4d3a2a4 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -162,6 +162,11 @@ export const storyApi = { return response.data; }, + getStoriesByAuthor: async (authorId: string, params?: { page?: number; size?: number }): Promise> => { + const response = await api.get(`/stories/author/${authorId}`, { params }); + return response.data; + }, + getStory: async (id: string): Promise => { const response = await api.get(`/stories/${id}`); return response.data;