Skip to content

Commit 4645d07

Browse files
committed
Clean up nits
1 parent a2fbe34 commit 4645d07

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/tools/atlas/read/getPerformanceAdvisor.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
getSchemaAdvice,
1010
getSlowQueries,
1111
} from "../../../common/atlas/performanceAdvisorUtils.js";
12+
import { AtlasArgs } from "../../args.js";
1213

1314
const PerformanceAdvisorOperationType = z.enum([
1415
"suggestedIndexes",
@@ -23,13 +24,16 @@ export class GetPerformanceAdvisorTool extends AtlasToolBase {
2324
"Get MongoDB Atlas performance advisor recommendations, which includes the operations: suggested indexes, drop index suggestions, slow query logs, and schema suggestions";
2425
public operationType: OperationType = "read";
2526
protected argsShape = {
26-
projectId: z.string().describe("Atlas project ID to get performance advisor recommendations"),
27-
clusterName: z.string().describe("Atlas cluster name to get performance advisor recommendations"),
27+
projectId: AtlasArgs.projectId().describe("Atlas project ID to get performance advisor recommendations"),
28+
clusterName: AtlasArgs.clusterName().describe("Atlas cluster name to get performance advisor recommendations"),
2829
operations: z
2930
.array(PerformanceAdvisorOperationType)
3031
.default(PerformanceAdvisorOperationType.options)
3132
.describe("Operations to get performance advisor recommendations"),
32-
since: z.date().describe("Date to get slow query logs since").optional(),
33+
since: z
34+
.date()
35+
.describe("Date to get slow query logs since. Only relevant for the slowQueryLogs operation.")
36+
.optional(),
3337
namespaces: z
3438
.array(z.string())
3539
.describe("Namespaces to get slow query logs. Only relevant for the slowQueryLogs operation.")
@@ -48,29 +52,29 @@ export class GetPerformanceAdvisorTool extends AtlasToolBase {
4852
await Promise.all([
4953
operations.includes("suggestedIndexes")
5054
? getSuggestedIndexes(this.session.apiClient, projectId, clusterName)
51-
: { suggestedIndexes: [] },
55+
: undefined,
5256
operations.includes("dropIndexSuggestions")
5357
? getDropIndexSuggestions(this.session.apiClient, projectId, clusterName)
54-
: { hiddenIndexes: [], redundantIndexes: [], unusedIndexes: [] },
58+
: undefined,
5559
operations.includes("slowQueryLogs")
5660
? getSlowQueries(this.session.apiClient, projectId, clusterName, since, namespaces)
57-
: { slowQueryLogs: [] },
61+
: undefined,
5862
operations.includes("schemaSuggestions")
5963
? getSchemaAdvice(this.session.apiClient, projectId, clusterName)
60-
: { recommendations: [] },
64+
: undefined,
6165
]);
6266

6367
const performanceAdvisorData = [
64-
suggestedIndexesResult?.suggestedIndexes?.length > 0
68+
suggestedIndexesResult && suggestedIndexesResult?.suggestedIndexes?.length > 0
6569
? `## Suggested Indexes\n${JSON.stringify(suggestedIndexesResult.suggestedIndexes)}`
6670
: "No suggested indexes found.",
6771
dropIndexSuggestionsResult
6872
? `## Drop Index Suggestions\n${JSON.stringify(dropIndexSuggestionsResult)}`
6973
: "No drop index suggestions found.",
70-
slowQueryLogsResult?.slowQueryLogs?.length > 0
74+
slowQueryLogsResult && slowQueryLogsResult?.slowQueryLogs?.length > 0
7175
? `## Slow Query Logs\n${JSON.stringify(slowQueryLogsResult.slowQueryLogs)}`
7276
: "No slow query logs found.",
73-
schemaSuggestionsResult?.recommendations?.length > 0
77+
schemaSuggestionsResult && schemaSuggestionsResult?.recommendations?.length > 0
7478
? `## Schema Suggestions\n${JSON.stringify(schemaSuggestionsResult.recommendations)}`
7579
: "No schema suggestions found.",
7680
];

0 commit comments

Comments
 (0)