fix: load complete temporal dataset inventory
GeoIntel CI / docs-smoke (push) Canceled after 0s
GeoIntel CI / contract-smoke (push) Canceled after 0s

This commit is contained in:
Codex
2026-07-15 12:22:37 +02:00
parent fb38eb3e91
commit 232e8c2126
5 changed files with 66 additions and 4 deletions
+28 -2
View File
@@ -20,9 +20,35 @@ import type {
OrthophotoProductRead,
} from '../../types'
const DATASET_PAGE_SIZE = 200
async function listProjectDatasets(projectId: string): Promise<DatasetListResponse> {
const items: DatasetCreateResponse[] = []
let offset = 0
let total: number | null = null
do {
const page = await apiGet<DatasetListResponse>(
`/api/v1/projects/${projectId}/datasets?limit=${DATASET_PAGE_SIZE}&offset=${offset}`,
)
if (total === null) {
total = page.total
} else if (page.total !== total) {
throw new Error('De datasetlijst wijzigde tijdens het laden. Vernieuw de werkruimte.')
}
items.push(...page.items)
if (page.items.length === 0) {
break
}
offset += page.items.length
} while (offset < (total ?? 0))
if (total !== null && items.length !== total) {
throw new Error(`Niet alle datasets konden worden geladen (${items.length}/${total}).`)
}
return { items, total: total ?? 0, limit: items.length, offset: 0 }
}
export const datasetsApi = {
list: (projectId: string): Promise<DatasetListResponse> =>
apiGet<DatasetListResponse>(`/api/v1/projects/${projectId}/datasets`),
list: listProjectDatasets,
upload: (
projectId: string,
payload: {