Skip to content

MIGRATION-796#183

Open
idarowan wants to merge 1 commit intomasterfrom
MIGRATION-796
Open

MIGRATION-796#183
idarowan wants to merge 1 commit intomasterfrom
MIGRATION-796

Conversation

@idarowan
Copy link
Copy Markdown
Collaborator

@idarowan idarowan commented Apr 9, 2026

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 so accesses appears next to accesses_since for 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.

@idarowan idarowan requested a review from BigMarcio April 9, 2026 10:10
Copy link
Copy Markdown
Collaborator

@BigMarcio BigMarcio left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 indexKeyPattern to exported index stats and refines field ordering (placing accesses next to accesses_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.

Comment on lines +24 to +25
- IndexStats.csv
- IndexStats.md
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
- IndexStats.csv
- IndexStats.md
- probIndexesComplete.csv
- probIndexesComplete.md

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +8
const csvOutputFile = 'probIndexesComplete.csv';
const mdOutputFile = 'probIndexesComplete.md';
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
const csvOutputFile = 'probIndexesComplete.csv';
const mdOutputFile = 'probIndexesComplete.md';
const csvOutputFile = 'IndexStats.csv';
const mdOutputFile = 'IndexStats.md';

Copilot uses AI. Check for mistakes.
Comment on lines +128 to +133
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
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
Comment on lines +36 to +37
function escapeCsv(value) {
const str = stringifyValue(value);
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
function escapeCsv(value) {
const str = stringifyValue(value);
function neutralizeCsvFormula(value) {
return /^[=+\-@]/.test(value) ? `'${value}` : value;
}
function escapeCsv(value) {
const str = neutralizeCsvFormula(stringifyValue(value));

Copilot uses AI. Check for mistakes.
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