Skip to content

Commit

Permalink
Dont ignore broken row
Browse files Browse the repository at this point in the history
  • Loading branch information
at-github committed Nov 18, 2024
1 parent 99988e3 commit 97d014f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/model/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 7 additions & 3 deletions src/services/export.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -36,6 +36,7 @@ export const exportDatasets = async (
availability: datasetProperties.availability,
uri: datasetProperties.uri
}

try {
const remoteDataset =
datasetProperties.id != null
Expand All @@ -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;' })
}

0 comments on commit 97d014f

Please sign in to comment.