From 3d5ba6b94e1921d1f77c298435fde40f5cf34914 Mon Sep 17 00:00:00 2001 From: Alireza Heidari Date: Thu, 25 Jul 2024 12:06:36 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F:=20update=20`getDatasets`?= =?UTF-8?q?=20to=20return=20`total=5Fmatches`=20and=20update=20the=20usage?= =?UTF-8?q?=20accordingly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/api/datasets.ts | 7 +++++-- client/src/components/Dataset/DatasetList.vue | 2 +- .../LibraryFolder/TopToolbar/HistoryDatasetPicker.vue | 10 +++------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/client/src/api/datasets.ts b/client/src/api/datasets.ts index ef5606450b64..3f1b2842e2ae 100644 --- a/client/src/api/datasets.ts +++ b/client/src/api/datasets.ts @@ -36,8 +36,11 @@ export async function getDatasets(options: GetDatasetsOptions = {}) { if (options.history_id) { params.history_id = options.history_id; } - const { data } = await datasetsFetcher(params); - return data; + const { data, headers } = await datasetsFetcher(params); + + const total_matches = parseInt(headers.get("total_matches") ?? "0"); + + return { data, total_matches }; } export const fetchDataset = fetcher.path("/api/datasets/{dataset_id}").method("get").create(); diff --git a/client/src/components/Dataset/DatasetList.vue b/client/src/components/Dataset/DatasetList.vue index 999b2cef6ff8..c2816114f529 100644 --- a/client/src/components/Dataset/DatasetList.vue +++ b/client/src/components/Dataset/DatasetList.vue @@ -68,7 +68,7 @@ async function load(concat = false) { loading.value = true; try { - const datasets = await getDatasets({ + const { data: datasets } = await getDatasets({ query: query.value, sortBy: sortBy.value, sortDesc: sortDesc.value, diff --git a/client/src/components/Libraries/LibraryFolder/TopToolbar/HistoryDatasetPicker.vue b/client/src/components/Libraries/LibraryFolder/TopToolbar/HistoryDatasetPicker.vue index d183a3c3a6cc..bdbcf689ff97 100644 --- a/client/src/components/Libraries/LibraryFolder/TopToolbar/HistoryDatasetPicker.vue +++ b/client/src/components/Libraries/LibraryFolder/TopToolbar/HistoryDatasetPicker.vue @@ -199,7 +199,7 @@ async function datasetsProvider(ctx: ItemsProviderContext, selectedHistory: Hist const offset = (ctx.currentPage - 1) * ctx.perPage; const query = ctx.filter; - const data = await getDatasets({ + const { data, total_matches } = await getDatasets({ history_id: selectedHistory.id, query: query, sortBy: ctx.sortBy === "time" ? "update_time" : "name", @@ -208,13 +208,9 @@ async function datasetsProvider(ctx: ItemsProviderContext, selectedHistory: Hist limit: limit, }); - items.value = (data as HDASummary[]).map(datasetEntryToRecord); + totalItems.value = total_matches; - if (query) { - totalItems.value = items.value.length; - } else { - totalItems.value = selectedHistory.size; - } + items.value = (data as HDASummary[]).map(datasetEntryToRecord); formatRows();