Skip to content

Conversation

Anemy
Copy link
Member

@Anemy Anemy commented Jun 29, 2021

COMPASS-4537 COMPASS-4906

This PR fixes a couple bugs around import/export:

  • Fixes opening the export modal by properly counting documents on time-series collections and views. The collection function estimatedDocumentCount errors on views and time-series collections, so now we use countDocuments. This is more expensive, so we could change up the ui here to either background load with a loader, or hide the count entirely. We do get to skip the count when we open the export from the export button on compass-crud by passing the count from the resulting query there.
  • Fixes showing the correct count for the query used to find the documents to be exported. Previously we would always show the estimated count, although we would export the expected amount of documents resulting from the query.
  • Fixes a small bug around showing undefined for an empty query (screenshot in comment).
  • Fixes opening the export collection modal from the app menu. Filed COMPASS-4911 which is a bug around using the app menu to open the import and export modals. This might be noticed more now that the export collection menu item works properly.
  • Fixes double listeners to the open-export and open-import app registry messages/events. Previously we had both of these modals sharing the same store and subscribing to the same messages/events. Didn't really cause any issues before, but now that we're supplying the correct count we probably don't want to be duplicating a possibly expensive countDocuments call.

export default function(ns, spec) {
let ret = `db.${toNS(ns).collection}.find(\n`;
ret += ' ' + stringify(spec.filter, '');
ret += ' ' + stringify(spec.filter ? spec.filter : {}, '');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes:
Screen Shot 2021-06-29 at 6 46 24 PM
Now:
Screen Shot 2021-06-29 at 6 48 40 PM

Copy link
Collaborator

@gribnoysup gribnoysup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

{
...(query.limit ? { limit: query.limit } : {} ),
...(query.skip ? { skip: query.skip } : {} )
}
Copy link
Collaborator

@mcasimir mcasimir Jun 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to handle a failure + add a maxTimeMs here? Something like return undefined and if the count is undefined we hide the number and the progress bar?

&& !query.skip
) {
try {
const runEstimatedDocumentCount = promisify(dataService.estimatedCount.bind(dataService));
Copy link
Collaborator

@mcasimir mcasimir Jun 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea! Maybe we could add a debug call for when it fails.

Copy link
Collaborator

@mcasimir mcasimir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow the amount of fixes :)

@gribnoysup gribnoysup merged commit 938333b into main Jun 30, 2021
@gribnoysup gribnoysup deleted the COMPASS-4906-4 branch June 30, 2021 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants