Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions frontend/server/api/collection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,21 @@ export default defineEventHandler(async (event): Promise<Pagination<Collection>
orderByDirection,
});

type CollectionCount = {'count(id)': number};
const collectionCountResult = await fetchFromTinybird<CollectionCount[]>('/v0/pipes/collections_list.json', {
count: true,
});

const data: Pagination<Collection> = {
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'});
}
});
9 changes: 7 additions & 2 deletions frontend/server/api/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,21 @@ export default defineEventHandler(async (event): Promise<Pagination<Project> | E
orderByDirection,
});

type ProjectCount = {'count(id)': number};
const projectCountResult = await fetchFromTinybird<ProjectCount[]>('/v0/pipes/projects_list.json', {
count: true,
});

const data: Pagination<Project> = {
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'});
}
});