From cc6b61c45e7cc94ede00f670858700924fa6d090 Mon Sep 17 00:00:00 2001 From: Anemy Date: Wed, 16 Jun 2021 13:37:50 -0400 Subject: [PATCH 1/2] gs --- .../src/components/stage-preview/stage-preview.jsx | 2 +- packages/compass-aggregations/src/modules/pipeline.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/compass-aggregations/src/components/stage-preview/stage-preview.jsx b/packages/compass-aggregations/src/components/stage-preview/stage-preview.jsx index 5cfb07330db..1dad48220fc 100644 --- a/packages/compass-aggregations/src/components/stage-preview/stage-preview.jsx +++ b/packages/compass-aggregations/src/components/stage-preview/stage-preview.jsx @@ -46,7 +46,7 @@ class StagePreview extends Component { } /** - * On the save click, execute the $out. + * On the save click, execute the $out or $merge. */ onSaveDocuments = () => { this.props.runOutStage(this.props.index); diff --git a/packages/compass-aggregations/src/modules/pipeline.js b/packages/compass-aggregations/src/modules/pipeline.js index 177216a4edd..88baf2dde11 100644 --- a/packages/compass-aggregations/src/modules/pipeline.js +++ b/packages/compass-aggregations/src/modules/pipeline.js @@ -534,8 +534,7 @@ export const generatePipeline = (state, index) => { if ( stages.length > 0 && - !REQUIRED_AS_FIRST_STAGE.includes(lastStage.stageOperator) && - (lastStage.stageOperator !== MERGE) + !REQUIRED_AS_FIRST_STAGE.includes(lastStage.stageOperator) ) { stages.push({ $limit: state.limit || DEFAULT_SAMPLE_SIZE @@ -593,6 +592,12 @@ const aggregate = (pipeline, dataService, ns, dispatch, state, index) => { options.collation = state.collation; } + /// // aaaaa + // console.log('refreshInputDocuments w/ limit:', state.settings.sampleSize); + // debugger; + console.log('aggregate w/ pipeline', JSON.parse(JSON.stringify(pipeline))); + console.log('options:', options); + dataService.aggregate(ns, pipeline, options, (err, cursor) => { if (err) return dispatch(stagePreviewUpdated([], index, err)); cursor.toArray((e, docs) => { @@ -627,7 +632,7 @@ const executeStage = (dataService, ns, dispatch, state, index) => { }; /** - * Executes the out stage. + * Executes a pipeline that outputs documents as the last stage. * * @param {DataService} dataService - The data service. * @param {String} ns - The namespace. From 404b67557efb9c5636a257bdd67a7ede92922e71 Mon Sep 17 00:00:00 2001 From: Anemy Date: Wed, 16 Jun 2021 13:38:08 -0400 Subject: [PATCH 2/2] remove explicit merge check --- packages/compass-aggregations/src/modules/pipeline.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/compass-aggregations/src/modules/pipeline.js b/packages/compass-aggregations/src/modules/pipeline.js index 88baf2dde11..3843c9da446 100644 --- a/packages/compass-aggregations/src/modules/pipeline.js +++ b/packages/compass-aggregations/src/modules/pipeline.js @@ -592,12 +592,6 @@ const aggregate = (pipeline, dataService, ns, dispatch, state, index) => { options.collation = state.collation; } - /// // aaaaa - // console.log('refreshInputDocuments w/ limit:', state.settings.sampleSize); - // debugger; - console.log('aggregate w/ pipeline', JSON.parse(JSON.stringify(pipeline))); - console.log('options:', options); - dataService.aggregate(ns, pipeline, options, (err, cursor) => { if (err) return dispatch(stagePreviewUpdated([], index, err)); cursor.toArray((e, docs) => {