Skip to content

Commit e88e0d0

Browse files
committed
fix: switch back to 10s intervals and round the number at the component
1 parent 500b292 commit e88e0d0

File tree

3 files changed

+5
-18
lines changed

3 files changed

+5
-18
lines changed

packages/compass-indexes/src/components/regular-indexes-table/regular-index-actions.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ const IndexActions: React.FunctionComponent<IndexActionsProps> = ({
124124
progressPercentage < 100 &&
125125
progressPercentage > 0
126126
) {
127-
const progressText = `${Math.round(progressPercentage)}%`;
128-
129127
return (
130128
<div
131129
className={combinedContainerStyles}
132130
data-testid="index-building-spinner"
133131
>
134-
<Body className={progressTextStyles}>Building... {progressText}</Body>
132+
<Body className={progressTextStyles}>
133+
Building... {progressPercentage | 0}%
134+
</Body>
135135
<SpinLoader size={16} title="Index build in progress" />
136136
<ItemActionGroup<IndexAction>
137137
data-testid="index-actions"

packages/compass-indexes/src/hooks/use-index-progress.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import type { InProgressIndex } from '../modules/regular-indexes';
44
import { getIndexesProgress } from '../modules/regular-indexes';
55
import type { IndexesThunkDispatch } from '../modules';
66

7-
/** 1 seconds polling interval */
8-
const INDEX_INIT_PROGRESS_POLLING_INTERVAL_MS = 1 * 1000;
97
/** 10 seconds polling interval */
108
const INDEX_PROGRESS_POLLING_INTERVAL_MS = 10 * 1000;
119

@@ -18,7 +16,6 @@ const INDEX_PROGRESS_POLLING_INTERVAL_MS = 10 * 1000;
1816
export function useIndexProgress(inProgressIndexes: InProgressIndex[]) {
1917
const dispatch = useDispatch<IndexesThunkDispatch>();
2018
const timeoutRef = useRef<number | undefined>(undefined);
21-
const checksRef = useRef<number>(0);
2219

2320
useEffect(() => {
2421
const indexesToTrack = inProgressIndexes.filter((index) => {
@@ -37,19 +34,11 @@ export function useIndexProgress(inProgressIndexes: InProgressIndex[]) {
3734
timeoutRef.current = undefined;
3835

3936
if (indexesToTrack.length) {
40-
checksRef.current = 0;
41-
4237
const updateIndexProgress = () => {
43-
checksRef.current += 1;
4438
void dispatch(getIndexesProgress(indexesToTrack)).finally(() => {
4539
if (timeoutRef.current) {
4640
// After the first 3 checks, slow down the poller
47-
setTimeout(
48-
updateIndexProgress,
49-
checksRef.current < 3
50-
? INDEX_INIT_PROGRESS_POLLING_INTERVAL_MS
51-
: INDEX_PROGRESS_POLLING_INTERVAL_MS
52-
);
41+
setTimeout(updateIndexProgress, INDEX_PROGRESS_POLLING_INTERVAL_MS);
5342
}
5443
});
5544
};

packages/compass-indexes/src/modules/regular-indexes.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,7 @@ export const getIndexesProgress = (
646646

647647
for (const op of createIndexOps) {
648648
if (op.command?.indexes && op.progress) {
649-
const percentage = Math.round(
650-
(op.progress.done / op.progress.total) * 100
651-
);
649+
const percentage = (op.progress.done / op.progress.total) * 100;
652650

653651
// Add progress for all indexes in this operation
654652
for (const idx of op.command.indexes) {

0 commit comments

Comments
 (0)