diff --git a/frontend/server/api/collection/index.ts b/frontend/server/api/collection/index.ts index 7f37ee38d..e81afb235 100644 --- a/frontend/server/api/collection/index.ts +++ b/frontend/server/api/collection/index.ts @@ -41,16 +41,21 @@ export default defineEventHandler(async (event): Promise orderByDirection, }); + type CollectionCount = {'count(id)': number}; + const collectionCountResult = await fetchFromTinybird('/v0/pipes/collections_list.json', { + count: true, + }); + const data: Pagination = { page, pageSize, - total: res.rows, + total: collectionCountResult.data[0]?.['count(id)'] || 0, data: res.data, } return data } catch (error) { - console.error('Error collection list:', error); + console.error('Error fetching collection list from TinyBird:', error); throw createError({statusCode: 500, statusMessage: 'Internal Server Error'}); } }); diff --git a/frontend/server/api/project/index.ts b/frontend/server/api/project/index.ts index b61aa2949..a1f886ed1 100644 --- a/frontend/server/api/project/index.ts +++ b/frontend/server/api/project/index.ts @@ -56,16 +56,21 @@ export default defineEventHandler(async (event): Promise | E orderByDirection, }); + type ProjectCount = {'count(id)': number}; + const projectCountResult = await fetchFromTinybird('/v0/pipes/projects_list.json', { + count: true, + }); + const data: Pagination = { page, pageSize, - total: res.rows, + total: projectCountResult.data[0]?.['count(id)'] || 0, data: res.data, } return data; } catch (error) { - console.error('Error fetching project list:', error); + console.error('Error fetching project list from TinyBird:', error); throw createError({statusCode: 500, statusMessage: 'Internal Server Error'}); } });