Skip to content

MRVA: Export results to local markdown files #1344

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

Merged
merged 4 commits into from
May 17, 2022

Conversation

shati-patel
Copy link
Contributor

Expands on the exporting functionality from #1341 to allow exporting to local markdown instead of gist. A pop-up gives you the location of the saved markdown, and lets you open the summary file. (You can also find the markdown files later, via the "Open query directory" command in the query history.)

Here's a little GIF:

demo of exporting variant analysis to local markdown

(See internal issue for more info 🔍 )

Checklist

N/A - internal only 🦔

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

@shati-patel shati-patel requested review from a team as code owners May 12, 2022 13:40
`Variant analysis results exported to \"${basePath}\".`,
'Open exported results'
);
if (shouldOpenSummary) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there an obvious way for a user to get access to the file itself? Presumably, if they create this file, they want to send it to someone. What is the simplest process for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, that's a good point. You can currently access the results files in the "query directory" from here:
image

That isn't at all obvious though 😅 Perhaps we could put all the results in a "exported results" subdirectory of the query directory, and then open that directory instead of just opening the summary file?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that would work. Could you do both? ie- open the markdown file as an editor as well as open the exported results directory? I think it's nice to see the prettified markdown version of the results.

Comment on lines 106 to 107
queryHistoryManager: QueryHistoryManager,
queryHistoryItem: QueryHistoryInfo,
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: I see you are passing in two parameters here, queryHistoryManager and queryHistoryItem, only being used to get the basePath. It might be simpler to get the basePath outside of this function and pass it in as a parameter.

It cuts down on the # of parameters to this function by one, avoids an import

);
for (const markdownFile of markdownFiles) {
const filePath = path.join(basePath, `${markdownFile.fileName}.md`);
await fs.writeFile(filePath, markdownFile.content.join('\n'), 'utf8');
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you tested whether this works if you export multiple times? I think it should, but can't be bothered checking the docs 😬

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, right...one thing we're going to need to think about is exporting multiple times with different selections. Presumably, we are going to want to delete the old results before creating new ones. Is this something we can implement later?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think we can worry about that a bit later on!

I specifically meant running the export multiple times e.g. maybe I forgot I already exported stuff and I tried it again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exporting the same thing multiple times works fine!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess we technically overwrite the markdown files every time though 🤔 Would that be a problem? Perhaps we should check if the files exist first?

Copy link
Contributor

Choose a reason for hiding this comment

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

Exporting the same thing multiple times works fine!

My concern is about exporting a slightly different selection each time. Since selection isn't implemented yet, we don't need to worry about it until later, but this is something we should keep in mind.

);
for (const markdownFile of markdownFiles) {
const filePath = path.join(basePath, `${markdownFile.fileName}.md`);
await fs.writeFile(filePath, markdownFile.content.join('\n'), 'utf8');
Copy link
Contributor

Choose a reason for hiding this comment

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

Exporting the same thing multiple times works fine!

My concern is about exporting a slightly different selection each time. Since selection isn't implemented yet, we don't need to worry about it until later, but this is something we should keep in mind.

for (const markdownFile of markdownFiles) {
const filePath = path.join(basePath, `${markdownFile.fileName}.md`);
const filePath = path.join(exportedResultsPath, `${markdownFile.fileName}.md`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice...so now all markdown files will live in a single directory. This will make it easier to manage and delete across exports.

@shati-patel shati-patel merged commit 9367d5f into main May 17, 2022
@shati-patel shati-patel deleted the shati-patel/local-export branch May 17, 2022 09:03
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