Conversation
There was a problem hiding this comment.
Pull request overview
Enhances the probIndexesComplete MongoDB index utilization script to generate more structured index insights (including indexKeyPattern) and export results to shareable file formats.
Changes:
- Adds
indexKeyPatternto exported index stats and refines field ordering (placingaccessesnext toaccesses_since). - Adds CSV + Markdown export functionality (file writing + basic formatting/escaping).
- Updates README with an “Expected Output Files” section.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| migration/toolbox/probIndexesComplete/README.md | Documents expected output artifacts produced by the script. |
| migration/toolbox/probIndexesComplete/probIndexesComplete.js | Collects index stats and writes results to CSV/Markdown output files (plus output formatting helpers). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - IndexStats.csv | ||
| - IndexStats.md |
There was a problem hiding this comment.
The README lists expected output files as IndexStats.csv and IndexStats.md, but the script writes probIndexesComplete.csv/.md. Update the README to match the actual output filenames (or rename the script output files to match the docs) to avoid confusion for users running the tool.
| - IndexStats.csv | |
| - IndexStats.md | |
| - probIndexesComplete.csv | |
| - probIndexesComplete.md |
| const csvOutputFile = 'probIndexesComplete.csv'; | ||
| const mdOutputFile = 'probIndexesComplete.md'; |
There was a problem hiding this comment.
The script writes output to probIndexesComplete.csv / probIndexesComplete.md, but the README’s new “Expected Output Files” section calls them IndexStats.csv / IndexStats.md. Align the constants here with the documented filenames (or adjust the README) so users can find the generated files reliably.
| const csvOutputFile = 'probIndexesComplete.csv'; | |
| const mdOutputFile = 'probIndexesComplete.md'; | |
| const csvOutputFile = 'IndexStats.csv'; | |
| const mdOutputFile = 'IndexStats.md'; |
| writeCsv(indexesUtilization, csvOutputFile); | ||
| writeMarkdown(indexesUtilization, mdOutputFile); | ||
|
|
||
| print(`CSV output written to: ${csvOutputFile}`); | ||
| print(`Markdown output written to: ${mdOutputFile}`); | ||
| print(`Total indexes exported: ${indexesUtilization.length}`); No newline at end of file |
There was a problem hiding this comment.
The script no longer prints the index table to the console (it only prints file paths and totals). The README still includes an “Example Output” table and the PR description discusses improving output readability; consider restoring console.table(indexesUtilization) (or updating the README/PR description to clarify that output is now file-only).
| function escapeCsv(value) { | ||
| const str = stringifyValue(value); |
There was a problem hiding this comment.
CSV cells are always quoted/escaped, but values that begin with =, +, -, or @ can still be interpreted as formulas by spreadsheet apps (CSV injection). Since index names/keys can be user-controlled, consider neutralizing those leading characters (e.g., prefix with a single quote) before writing CSV.
| function escapeCsv(value) { | |
| const str = stringifyValue(value); | |
| function neutralizeCsvFormula(value) { | |
| return /^[=+\-@]/.test(value) ? `'${value}` : value; | |
| } | |
| function escapeCsv(value) { | |
| const str = neutralizeCsvFormula(stringifyValue(value)); |
This update enhances the index utilization script to provide more accurate, structured, and exportable insights. The output now includes the
indexKeyPattern, allowing visibility into the actual index structure rather than relying solely on index names. The column order has also been refined soaccessesappears next toaccesses_sincefor better readability. A typo in the index type label was corrected from “commom” to “common”.In addition, the script now supports exporting results to both CSV and Markdown files, making it easier to share, review, and use the data outside of the terminal.