diff --git a/lib/galaxy/webapps/galaxy/api/datasets.py b/lib/galaxy/webapps/galaxy/api/datasets.py index fdc790d9fd96..73a06eaf0d66 100644 --- a/lib/galaxy/webapps/galaxy/api/datasets.py +++ b/lib/galaxy/webapps/galaxy/api/datasets.py @@ -143,6 +143,7 @@ class FastAPIDatasets: ) def index( self, + response: Response, trans=DependsOnTrans, history_id: Optional[DecodedDatabaseIdField] = Query( default=None, @@ -151,7 +152,9 @@ def index( serialization_params: SerializationParams = Depends(query_serialization_params), filter_query_params: FilterQueryParams = Depends(get_filter_query_params), ) -> List[AnyHistoryContentItem]: - return self.service.index(trans, history_id, serialization_params, filter_query_params) + entries, total_matches = self.service.index(trans, history_id, serialization_params, filter_query_params) + response.headers["total_matches"] = str(total_matches) + return entries @router.get( "/api/datasets/{dataset_id}/storage", diff --git a/lib/galaxy/webapps/galaxy/services/datasets.py b/lib/galaxy/webapps/galaxy/services/datasets.py index 25dc26b5bb09..5ac2ce3b8461 100644 --- a/lib/galaxy/webapps/galaxy/services/datasets.py +++ b/lib/galaxy/webapps/galaxy/services/datasets.py @@ -325,7 +325,7 @@ def index( history_id: Optional[DecodedDatabaseIdField], serialization_params: SerializationParams, filter_query_params: FilterQueryParams, - ) -> List[AnyHistoryContentItem]: + ) -> Tuple[List[AnyHistoryContentItem], int]: """ Search datasets or collections using a query system and returns a list containing summary of dataset or dataset_collection information. @@ -345,12 +345,20 @@ def index( order_by=order_by, user_id=user.id, ) - return [ - self.serializer_by_type[content.history_content_type].serialize_to_view( - content, user=user, trans=trans, encode_id=False, **serialization_params.model_dump() - ) - for content in contents - ] + total_matches = self.history_contents_manager.contents_count( + container=container, + filters=filters, + user_id=user.id, + ) + return ( + [ + self.serializer_by_type[content.history_content_type].serialize_to_view( + content, user=user, trans=trans, encode_id=False, **serialization_params.model_dump() + ) + for content in contents + ], + total_matches, + ) def show( self,