Skip to content

Commit

Permalink
🛠️: update getDatasets to return total_matches and update the usa…
Browse files Browse the repository at this point in the history
…ge accordingly
  • Loading branch information
itisAliRH committed Aug 2, 2024
1 parent 6806709 commit 3d5ba6b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
7 changes: 5 additions & 2 deletions client/src/api/datasets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Dataset/DatasetList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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();
Expand Down

0 comments on commit 3d5ba6b

Please sign in to comment.