Skip to content

Commit

Permalink
fix index attempt refreshing automatically (danswer-ai#2791)
Browse files Browse the repository at this point in the history
Co-authored-by: Richard Kuo <[email protected]>
  • Loading branch information
rkuo-danswer and LostVector authored Oct 15, 2024
1 parent efe2e79 commit aa5be37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion web/src/app/admin/connector/[ccPairId]/IndexingAttemptsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export function IndexingAttemptsTable({ ccPair }: { ccPair: CCPairFullInfo }) {
if (!cachedBatches[0]) {
fetchBatchData(0);
}
}, [ccPair.id, page, cachedBatches, totalPages]);
}, [ccPair.id, page, cachedBatches, totalPages, fetchBatchData]);

// This updates the data on the current page
useEffect(() => {
Expand All @@ -160,6 +160,15 @@ export function IndexingAttemptsTable({ ccPair }: { ccPair: CCPairFullInfo }) {
}
}, [page, cachedBatches]);

useEffect(() => {
const interval = setInterval(() => {
const batchNum = Math.floor((page - 1) / BATCH_SIZE);
fetchBatchData(batchNum); // Re-fetch the current batch data
}, 5000); // Refresh every 5 seconds

return () => clearInterval(interval); // Cleanup on unmount
}, [page, fetchBatchData]); // Dependencies to ensure correct batch is fetched

// This updates the page number and manages the URL
const updatePage = (newPage: number) => {
setPage(newPage);
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/admin/connector/[ccPairId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function Main({ ccPairId }: { ccPairId: number }) {
) {
finishConnectorDeletion();
}
}, [isLoading, ccPair, error, hasLoadedOnce]);
}, [isLoading, ccPair, error, hasLoadedOnce, finishConnectorDeletion]);

const handleNameChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setEditableName(e.target.value);
Expand Down

0 comments on commit aa5be37

Please sign in to comment.