Skip to content

Commit 8ebe5ba

Browse files
committed
fix(compass-import-export): remove re-count when not available COMPASS-5179, COMPASS-6649 (#4237)
1 parent 3ece062 commit 8ebe5ba

File tree

3 files changed

+13
-25
lines changed

3 files changed

+13
-25
lines changed

packages/compass-import-export/src/modules/cursor-exporter.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export class CursorExporter extends EventEmitter {
1717
private _output: stream.Writable;
1818
private _formatter;
1919
private _columns: Array<string> | boolean;
20-
private _totalNumberOfDocuments: number;
2120
private _exportedDocuments = 0;
2221
private _cursorStream: stream.Readable;
2322
constructor(opts: CursorExporterOpts) {
@@ -28,7 +27,6 @@ export class CursorExporter extends EventEmitter {
2827
opts.type === 'csv' ? createCSVFormatter : createJSONFormatter;
2928
this._output = opts.output;
3029
this._columns = opts.columns ? opts.columns : true;
31-
this._totalNumberOfDocuments = opts.totalNumberOfDocuments || 0;
3230
}
3331

3432
async start(): Promise<void> {

packages/compass-import-export/src/modules/export.spec.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ describe('export [module]', function () {
5353

5454
store.dispatch(dataServiceConnected(null, dataService));
5555
store.dispatch(globalAppRegistryActivated(globalAppRegistry));
56-
57-
// Manually awaiting a thunk to make sure that store is ready for the
58-
// tests
59-
await store.dispatch(
56+
store.dispatch(
6057
actions.openExport({
6158
namespace: TEST_COLLECTION_NAME,
6259
query: {},
@@ -70,7 +67,14 @@ describe('export [module]', function () {
7067
fileType,
7168
tempFile
7269
) {
73-
store.dispatch(actions.openExport('foo.bar', { filter: {} }, 0, null));
70+
store.dispatch(
71+
actions.openExport({
72+
namespace: TEST_COLLECTION_NAME,
73+
query: { filter: {} },
74+
count: 0,
75+
aggregation: undefined,
76+
})
77+
);
7478
store.dispatch(actions.updateSelectedFields(selectedFields));
7579
store.dispatch(actions.selectExportFileName(tempFile));
7680
store.dispatch(actions.selectExportFileType(fileType));

packages/compass-import-export/src/modules/export.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -398,28 +398,15 @@ export const openExport =
398398
}: {
399399
namespace: string;
400400
query: ExportQueryType;
401-
// Optional pre supplied count to shortcut and
402-
// avoid a possibly expensive re-count.
401+
// Optional pre supplied count, this helps us show progress.
403402
count?: number;
404403
aggregation?: ExportAggregationType;
405-
}): ThunkAction<Promise<void>, RootExportState, void, AnyAction> =>
406-
async (dispatch, getState) => {
404+
}) =>
405+
(dispatch: Dispatch) => {
407406
const isAggregation = !!aggregation;
408407
track('Export Opened', { type: isAggregation ? 'aggregation' : 'query' });
409-
const {
410-
dataService: { dataService },
411-
} = getState();
412408

413-
let count = null;
414-
try {
415-
count =
416-
maybeCount ??
417-
(!isAggregation
418-
? await fetchDocumentCount(dataService!, namespace, query)
419-
: null);
420-
} catch (e: unknown) {
421-
dispatch(onError(e as Error));
422-
}
409+
const count = maybeCount ?? null;
423410
dispatch(nsChanged(namespace));
424411
dispatch(onModalOpen({ namespace, query, count, aggregation }));
425412
};
@@ -495,7 +482,6 @@ export const startExport =
495482
type: exportData.fileType,
496483
columns: columns,
497484
output: dest,
498-
totalNumberOfDocuments: numDocsToExport,
499485
});
500486

501487
const throttledProgress = throttle(

0 commit comments

Comments
 (0)