From 97d014f23bffac2167c6557104bd9db5cd5bf17a Mon Sep 17 00:00:00 2001 From: Tarik Amar Date: Mon, 18 Nov 2024 15:34:24 +0100 Subject: [PATCH] Dont ignore broken row --- src/model/topic.ts | 3 ++- src/services/export.ts | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/model/topic.ts b/src/model/topic.ts index bb0ba4ae2..a75377805 100644 --- a/src/model/topic.ts +++ b/src/model/topic.ts @@ -10,7 +10,8 @@ export enum Availability { MISSING = 'missing', NOT_AVAILABLE = 'not available', LOCAL_AVAILABLE = 'available', - URL_AVAILABLE = 'url available' + URL_AVAILABLE = 'url available', + REMOTE_DELETED = 'Remote deleted' } export interface DatasetProperties { diff --git a/src/services/export.ts b/src/services/export.ts index 4e9cc5975..b023ca456 100644 --- a/src/services/export.ts +++ b/src/services/export.ts @@ -1,6 +1,6 @@ import { Parser } from '@json2csv/plainjs' -import type { DatasetProperties } from '@/model/topic' +import { Availability, type DatasetProperties } from '@/model/topic' import { useDatasetStore } from '@/store/DatasetStore' interface DatasetRow { @@ -36,6 +36,7 @@ export const exportDatasets = async ( availability: datasetProperties.availability, uri: datasetProperties.uri } + try { const remoteDataset = datasetProperties.id != null @@ -49,17 +50,20 @@ export const exportDatasets = async ( row.description = remoteDataset.description row.last_update = remoteDataset.last_update row.organization = remoteDataset.organization?.name - - return row } catch (error) { console.error( `Unable to load datasetProperties: ${datasetProperties.id}`, error ) + row.availability = Availability.REMOTE_DELETED + row.uri = null + } finally { + return row } }) ) const parser = new Parser({ fields: headers }) const csv = parser.parse(rows) + return new Blob([csv], { type: 'text/csv;charset=utf-8;' }) }