Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(aggregation-explain): show indexes COMPASS-5879 #3172

Merged
merged 4 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,14 @@ export const ExplainQueryPerformance: React.FunctionComponent<ExplainQueryPerfor
<Body weight="medium">{executionTimeMillis}</Body>
</div>
)}
<div className={statItemStyles}>
<Body className={statTitleStyles}>
Query used the following indexes:
</Body>
<Body weight="medium">
{indexes.length === 0
? 'No index available for this query.'
: indexes.length}
</Body>
</div>
{indexes.length > 0 && (
<div className={statItemStyles}>
<Body className={statTitleStyles}>
Query used the following indexes:
</Body>
<Body weight="medium">{indexes.length}</Body>
</div>
)}
<ExplainIndexes indexes={indexes} />
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,9 @@ describe('PipelineExplain', function () {

expect(within(summary).getByText(/documents returned/gi)).to.exist;
expect(within(summary).getByText(/actual query execution time/gi)).to.exist;
expect(within(summary).getByText(/query used the following indexes/gi)).to
.exist;
expect(within(summary).getByText(/no index available for this query./gi)).to
.exist;

expect(() => {
within(summary).getByText(/query used the following indexes/gi);
}).to.throw;
expect(screen.getByTestId('pipeline-explain-footer-close-button')).to.exist;
});

Expand Down
9 changes: 3 additions & 6 deletions packages/compass-aggregations/src/modules/explain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,13 @@ const mapIndexesInformation = function (
return explainIndexes
.filter(x => x.index)
.map((explainIndex) => {
const index = collectionIndexes.find(
const collectionIndex = collectionIndexes.find(
Copy link
Member

Choose a reason for hiding this comment

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

Do we / should we test this function/module? I'm thinking it could help prevent any regressions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done :)

(collectionIndex) => collectionIndex.name === explainIndex.index
);
if (!index) {
return null;
}
return {
name: index.name,
name: explainIndex.index,
shard: explainIndex.shard,
key: index.key,
key: collectionIndex?.key ?? {},
};
})
.filter(Boolean) as ExplainIndex[];
Expand Down