Delete rows in chunks
This commit is contained in:
@@ -55,11 +55,17 @@ const DeleteDatasetEntriesModal = ({ disclosure }: { disclosure: UseDisclosureRe
|
||||
|
||||
const [deleteRows, deletionInProgress] = useHandledAsyncCallback(async () => {
|
||||
if (!dataset?.id || !selectedIds.size) return;
|
||||
|
||||
// divide selectedIds into chunks of 15000 to reduce request size
|
||||
const chunkSize = 15000;
|
||||
const idsArray = Array.from(selectedIds);
|
||||
for (let i = 0; i < idsArray.length; i += chunkSize) {
|
||||
const response = await deleteRowsMutation.mutateAsync({
|
||||
ids: Array.from(selectedIds),
|
||||
ids: idsArray.slice(i, i + chunkSize),
|
||||
});
|
||||
|
||||
if (maybeReportError(response)) return;
|
||||
}
|
||||
|
||||
await utils.datasetEntries.list.invalidate();
|
||||
disclosure.onClose();
|
||||
|
||||
@@ -10,9 +10,10 @@ import {
|
||||
useDisclosure,
|
||||
} from "@chakra-ui/react";
|
||||
import Link from "next/link";
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import { AiOutlineDatabase } from "react-icons/ai";
|
||||
|
||||
import { env } from "~/env.mjs";
|
||||
import AppShell from "~/components/nav/AppShell";
|
||||
import { api } from "~/utils/api";
|
||||
import { useDataset, useHandledAsyncCallback } from "~/utils/hooks";
|
||||
@@ -126,7 +127,7 @@ export default function Dataset() {
|
||||
<FineTuneButton />
|
||||
<ImportDataButton />
|
||||
<ExperimentButton />
|
||||
<DownloadButton />
|
||||
{/* <DownloadButton /> */}
|
||||
<DeleteButton />
|
||||
</HStack>
|
||||
<DatasetEntriesTable />
|
||||
|
||||
Reference in New Issue
Block a user