Skip to content

Implement "open query directory" for variant analysis history items#1622

Merged
shati-patel merged 1 commit intomainfrom
shati-patel/open-query-dir
Oct 20, 2022
Merged

Implement "open query directory" for variant analysis history items#1622
shati-patel merged 1 commit intomainfrom
shati-patel/open-query-dir

Conversation

@shati-patel
Copy link
Copy Markdown
Contributor

@shati-patel shati-patel commented Oct 18, 2022

Adds the ability to open the query directory for a variant analysis history item. The "Open Query Directory" command in the query history context menu should now work for all kinds of history items 🎉

query history context menu

❓ Note: I've left a question inline about whether we need a timestamp file.

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.

Comment thread extensions/ql-vscode/src/remote-queries/variant-analysis-manager.ts Outdated
} else if (finalSingleItem.t === 'remote') {
externalFilePath = path.join(this.queryStorageDir, finalSingleItem.queryId, 'timestamp');
} else if (finalSingleItem.t === 'variant-analysis') {
externalFilePath = path.join(this.variantAnalysisManager.storagePath, finalSingleItem.variantAnalysis.id.toString(), 'timestamp');
Copy link
Copy Markdown
Contributor Author

@shati-patel shati-patel Oct 18, 2022

Choose a reason for hiding this comment

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

We don't yet create a timestamp file for variant analysis items, so we always fall back to this block:

if (!(await fs.pathExists(externalFilePath))) {
  // timestamp file is missing (manually deleted?) try selecting the parent folder.
  // It's less nice, but at least it will work.
  externalFilePath = path.dirname(externalFilePath);

This works fine, but should we be creating a timestamp file? (see https://github.com/github/vscode-codeql/blob/main/extensions/ql-vscode/src/helpers.ts#L560-L564)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't have full context but seems like we probably should create a timestamp file for new variant analyses. Seems we do this in the remote queries case by calling await this.prepareStorageDirectory(queryId); just before we trigger the monitoring command.

But as you explain, this is semi-independent of this PR because there's a fallback that covers us. So I'd suggest we add thetimestamp file but it doesn't necessarily have to be in this PR or block this PR.

@shati-patel shati-patel marked this pull request as ready for review October 18, 2022 16:19
@shati-patel shati-patel requested review from a team as code owners October 18, 2022 16:19
} else if (queryHistoryItem.t === 'remote') {
return path.join(this.queryStorageDir, queryHistoryItem.queryId);
} else if (queryHistoryItem.t === 'variant-analysis') {
return path.join(this.variantAnalysisManager.storagePath, queryHistoryItem.variantAnalysis.id.toString());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we make use of something like VariantAnalysisResultsManager.getStorageDirectory. Would need to make that method public, and expose the results manager through the variant analysis manager. Would appreciate thoughts on what the architecture of this should look like.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It feels like the variant analysis manager should know and be able to tell others about the storage location for a variant analysis. So I'd have:

variantAnalysisManager.getVariantAnalysisStorageLocation(variantAnalysisId: number): string {} 

and then call that from query history.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It does seem that this, along with the timestamp is something that should be done in a separate predecessor PR/issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fine by me to do it in a separate PR, either before or after this PR. 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point - I'm going to convert this PR to a draft for now and get the foundational stuff done in a separate PR first!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@shati-patel ok, I'll not do it here then: #1621

@shati-patel
Copy link
Copy Markdown
Contributor Author

Prep work in #1631! 🧹

@shati-patel shati-patel force-pushed the shati-patel/open-query-dir branch from 9a4ac13 to dab67f1 Compare October 19, 2022 15:32
@shati-patel shati-patel marked this pull request as ready for review October 19, 2022 15:40
@shati-patel
Copy link
Copy Markdown
Contributor Author

Thank you for the patience 😅

Rebased this on top of the changes from #1631 and tested that the query history command works. This should be actually ready for review now!

Copy link
Copy Markdown
Contributor

@robertbrignull robertbrignull left a comment

Choose a reason for hiding this comment

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

Yay! Thank you for making the other changes

@shati-patel shati-patel merged commit 4eecdbf into main Oct 20, 2022
@shati-patel shati-patel deleted the shati-patel/open-query-dir branch October 20, 2022 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants