From 2439eb8df204abd21369036847b6c5d11af048d6 Mon Sep 17 00:00:00 2001 From: Adam Kariv Date: Thu, 14 Nov 2024 12:33:15 +0200 Subject: [PATCH] Search datasets --- odds/api/common_endpoints.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/odds/api/common_endpoints.py b/odds/api/common_endpoints.py index fad0c1a..0c91375 100644 --- a/odds/api/common_endpoints.py +++ b/odds/api/common_endpoints.py @@ -56,16 +56,21 @@ async def fetch_dataset(id): publisher=dataset.publisher, publisher_description=dataset.publisher_description, link=dataset.link, - resources=[ - dict( - id=encode_id(f'{id}/{i}'), - name=resource.title, - num_rows=resource.row_count, - ) - for i, resource in enumerate(dataset.resources) - if resource.row_count - ], + resources=[] ) + for i, resource in enumerate(dataset.resources): + if resource.row_count: + response['resources'].append( + dict( + id=encode_id(f'{id}/{i}'), + name=resource.title, + num_rows=resource.row_count, + ) + ) + if resource.content: + response['resources'][-1]['content'] = resource.content + response['resources'][-1]['db_schema'] = 'no db schema available' + logging.debug('RESPONSE:', response) return response