Skip to content
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

Allow multiple analyses for same repo to be downloaded #1163

Merged
merged 2 commits into from Feb 23, 2022

Conversation

@aeisenberg
Copy link
Contributor

@aeisenberg aeisenberg commented Feb 22, 2022

Removes the limitation specified in #1089 where analyses for the same
repo and different queries will overwrite each other.

This PR does not save analysis results across restarts. After restarting, results will need to be re-downloaded. That is what I will work on next.

Checklist

  • [n/a] 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.
Removes the limitation specified in #1089 where analyses for the same
repo and different queries will overwrite each other.
@aeisenberg aeisenberg requested a review from as a code owner Feb 22, 2022
@@ -139,6 +146,6 @@ export class AnalysesResultsManager {
}

private isAnalysisDownloaded(analysis: AnalysisSummary): boolean {
return this.analysesResults.some(x => x.nwo === analysis.nwo);
return (this.analysesResults.get(analysis.downloadLink.queryId) || []).some(x => x.nwo === analysis.nwo);
Copy link
Contributor

@charisk charisk Feb 23, 2022

Choose a reason for hiding this comment

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

Here and in a few other places we do this.analysesResults.get(queryId) .. I think it'd be easier to read if we had a getQueryResults and did

Suggested change
return (this.analysesResults.get(analysis.downloadLink.queryId) || []).some(x => x.nwo === analysis.nwo);
return this.getQueryResults(queryId).some(x => x.nwo === analysis.nwo);

where getQueryResults is:

private getQueryResults(queryId: string) { 
  return this.analysesResults.get(analysis.downloadLink.queryId) || []
}

Copy link
Contributor Author

@aeisenberg aeisenberg Feb 23, 2022

Choose a reason for hiding this comment

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

There is already the getAnalysesResults, which is public. It makes a copy of the array before returning it. I can't use this method internally, since there is one place that relies on using the original array. Instead, I will make a internalGetAnalysesResults method that returns the results without copying them.

@@ -302,7 +302,7 @@ export async function runRemoteQuery(
message: 'Sending request'
});

const workflowRunId = await runRemoteQueriesApiRequest(credentials, 'main', language, repositories, owner, repo, base64Pack, dryRun);
const workflowRunId = await runRemoteQueriesApiRequest(credentials, 'better-errors', language, repositories, owner, repo, base64Pack, dryRun);
Copy link
Contributor

@charisk charisk Feb 23, 2022

Choose a reason for hiding this comment

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

Just checking we're intentionally checking this in. Fine if we decided to do that!

Copy link
Contributor Author

@aeisenberg aeisenberg Feb 23, 2022

Choose a reason for hiding this comment

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

This PR is broken unless we point to the better-errors branch. When that branch is merged on qc-run2, then we can change this back to main. I'll add a comment to that effect.

Base automatically changed from aeisenberg/remote-query-restart to main Feb 23, 2022
@aeisenberg aeisenberg merged commit c943c89 into main Feb 23, 2022
19 checks passed
@aeisenberg aeisenberg deleted the aeisenberg/remote-multi-analyses branch Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants