File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -41,16 +41,21 @@ export default defineEventHandler(async (event): Promise<Pagination<Collection>
4141 orderByDirection,
4242 } ) ;
4343
44+ type CollectionCount = { 'count(id)' : number } ;
45+ const collectionCountResult = await fetchFromTinybird < CollectionCount [ ] > ( '/v0/pipes/collections_list.json' , {
46+ count : true ,
47+ } ) ;
48+
4449 const data : Pagination < Collection > = {
4550 page,
4651 pageSize,
47- total : res . rows ,
52+ total : collectionCountResult . data [ 0 ] ?. [ 'count(id)' ] || 0 ,
4853 data : res . data ,
4954 }
5055
5156 return data
5257 } catch ( error ) {
53- console . error ( 'Error collection list:' , error ) ;
58+ console . error ( 'Error fetching collection list from TinyBird :' , error ) ;
5459 throw createError ( { statusCode : 500 , statusMessage : 'Internal Server Error' } ) ;
5560 }
5661} ) ;
Original file line number Diff line number Diff line change @@ -56,16 +56,21 @@ export default defineEventHandler(async (event): Promise<Pagination<Project> | E
5656 orderByDirection,
5757 } ) ;
5858
59+ type ProjectCount = { 'count(id)' : number } ;
60+ const projectCountResult = await fetchFromTinybird < ProjectCount [ ] > ( '/v0/pipes/projects_list.json' , {
61+ count : true ,
62+ } ) ;
63+
5964 const data : Pagination < Project > = {
6065 page,
6166 pageSize,
62- total : res . rows ,
67+ total : projectCountResult . data [ 0 ] ?. [ 'count(id)' ] || 0 ,
6368 data : res . data ,
6469 }
6570
6671 return data ;
6772 } catch ( error ) {
68- console . error ( 'Error fetching project list:' , error ) ;
73+ console . error ( 'Error fetching project list from TinyBird :' , error ) ;
6974 throw createError ( { statusCode : 500 , statusMessage : 'Internal Server Error' } ) ;
7075 }
7176} ) ;
You can’t perform that action at this time.
0 commit comments